PDA

View Full Version : [SOLVED] Combining commands



ibjsb4
March 1st, 2014, 03:44 PM
I think first time ever I posted in programming; I be running with the big dogs :D

Other than "&&" or ";;" is there a way to combine two move commands? Example:


sudo mv /var/lib/dpkg/status /var/lib/dpkg/status.broke
sudo mv /var/lib/dpkg/status-old /var/lib/dpkg/status

You can cat two files by:


cat filename1 filename2

trent.josephsen
March 1st, 2014, 05:22 PM
cat is a little different, since its actual job is to print as many files as you give it -- the name comes from "(con)catenate". mv's job is to move/rename one file, or to move a bunch of files into one directory.

However, for the given application, you may be in luck. (Not sure how portable the -b option is, it might only work with GNU mv.)


$ mv --backup --suffix=.broke /var/lib/dpkg/status-old /var/lib/dpkg/status
or to make that shorter
$ mv -bS.broke /var/lib/dpkg/status{-old,}

ibjsb4
March 1st, 2014, 06:08 PM
Thank you Trent, that’s what I was looking for.