//View Tip #177
» Using sed across multiple lines
» Ignore an alias
» The poor man's REPL
» Change file extension revisited
Pratik Sinha
Similar Tips
» Random xkcd comic» Using sed across multiple lines
» Ignore an alias
» The poor man's REPL
» Change file extension revisited
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:
You can see below how this can be used:
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
Comments
Add your comment
Comments are currently disabled
#1
Why not use simple 'cp'? whats the added advantage here?
Posted 2008-10-10 13:59:25
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

