//View Tip #46
Similar Tips
» swap files
» Permanent bash history
» Tar remote dir over SSH
» ssh proxy forwarding
» Store a directory name to come back to

 

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
Using expansion to move a file aside without having to type the file name twice

cp ReallyLongFileNameYouDontWantToTypeTwice{,.orig}


View Comments »



Comments 

Add your comment

CAPTCHA

No HTML allowed. URLs will be linked with nofollow attribute. Whitespace is preserved.

meh
explain it please?
Posted 2009-01-02 03:10:12
jeeks
is there something similar for really long paths?
Posted 2009-03-31 12:15:24
Explanation:

This uses brace expansion to create the two filenames (orignal and backup). Brace expansion generates a list of strings with each set of characters given in the braces. For example, "echo a{d,c,b}e" will give "ade ace abe".

In this case there is a blank for the first item and the second adds ".orig" for example:

cp file{,.orig}
Becomes:
cp file file.orig

This will indeed work with directories:

cp long/path/here/file{,.orig}
Posted 2009-03-31 12:29:26

Home Latest Browse Top 25 Random Hall Of Fame Contact Submit