//View Tip #177
Similar Tips
» ssh proxy forwarding
» Using Perl instead of Sed
» Duplicate directory tree
» Argument list too long
» Ignore an alias

 

Latest tips by RSS
Click here to subscribe
Follow Shell-Fu on Twitter
Click here to follow
Follow Shell-Fu on identi.ca
Click here to follow
Add the following alias and function to your profile to be able to copy and paste files at the command line:

ccopy(){ cp $1 /tmp/ccopy.$1; }
alias cpaste="ls /tmp/ccopy* | sed 's|[^\.]*.\.||' | xargs -I % mv /tmp/ccopy.% ./%"

You can see below how this can be used:
blackbird:~/tst tks1$ ls
1.txt   2.txt   t1.tss  t2.tss  t3.tss
blackbird:~/tst tks1$ ccopy 1.txt
blackbird:~/tst tks1$ ccopy 2.txt

blackbird:~/tst tks1$ cd ../tst2 blackbird:~/tst2 tks1$ ls
blackbird:~/tst2 tks1$ cpaste
blackbird:~/tst2 tks1$ ls 1.txt 2.txt


View Comments »



Comments 

Add your comment

Comments are currently disabled
Why not use simple 'cp'? whats the added advantage here?
Posted 2008-10-10 13:59:25
John
I guess the advantage is that you don't need to remember the full path to the file you're copying, you can just use the ccopy command, then carry on with what you're doing and use cpaste when you're ready to place the file.
Posted 2008-10-10 16:00:10
AdrianTM
Change:
ccopy(){ cp $1 /tmp/ccopy.$1; }

To:
ccopy(){ cp "$1" /tmp/ccopy."$1"; }

to handle blanks in file names.
Posted 2008-12-23 15:56:57

Home Latest Browse Top 25 Random Hall Of Fame Contact Submit