How do I modify bashrc to include a readme file with the pwd
to original source every time I use cp or mv?
It should be something like this:
alias cp="pwd $1 > readme & cp $1 $2"
or
alias cp="pwd $1 > readme | cp $1 $2"
But instead of the path of the source, it gives me the path of the directory I am in.
Answer
You can't have aliases with arguments. Since you probably don't have $1
defined, pwd $1
just expands to pwd
.
Also, pwd
doesn't actualy take any positional arguments. If you want the source to appear in readme, use echo
.
Create a function
cp() {
echo $1 > readme
/bin/cp $1 $2
}
Also,
&
does not mean AND – it sends processing to background|
does not mean OR – it pipes output of left side to input of right side
No comments:
Post a Comment