Minimal command to make a copy of a file
38,071
Yes,
cp /path/to/file/file1{,.kbp}
That will get expanded automatically to cp /path/to/file/file1 /path/to/file/file1.kbp
Related videos on Youtube
Author by
user13107
Updated on September 18, 2022Comments
-
user13107 almost 2 years
I often find myself copy-pasting long path in order to create a copy of a file
cp /path/to/file/file1 /path/to/file/file1.bkp
Is there an alternative utility that will NOT require me to type the path/to/file twice? Something like -
nameOfExecutible /path/to/file/file1 'bkp'
Note: I don't want to do a
cd
tofile1
s parent directory.-
Admin almost 5 yearsHow is this Question about copying files (with
cp
being the solution) a duplicate of a Question about using path withinmv
command? I suggest this valuable Question be re-opened.
-
-
user13107 over 11 yearsThanks. That saves so much time! Is there a terminology for those brackets?
-
Tim B over 11 yearsThe bash shell is expanding the expression in the curly braces prior to exec'ing cp. You can find it covered in the bash manual, or google for "bash brace expansion"
-
user3804598 almost 3 yearsbash brace expansion url