Home / Linux / Copying and renaming files on Linux

Copying and renaming files on Linux

Linux users have for many decades been using simple cp and mv commands to copy and rename files. These commands are some of the first that most of us learned and are used every day by possibly millions of people. But there are other techniques, handy variations and another command for renaming files that offers some unique options.

First, let’s think about why might you want to copy a file. You might need the same file in another location or you might want a copy because you’re going to edit the file and want to be sure you have a handy backup just in case you need to revert to the original file. The obvious way to do that is to use a command like “cp myfile myfile-orig”. If you want to copy a large number of files, however, that strategy might get old real fast. Better alternatives are to:

  • Use tar to create an archive of all of the files you want to back up before you start editing them
  • Use a for loop to make the backup copies easier

The tar option is very straightforward. For all files in the current directory, you’d use a command like:

$ tar cf myfiles.tar *

For a group of files that you can identify with a pattern, you’d use a command like this:


>> Source Link

Check Also

3 Ways to Resize Photos / Images Online WITHOUT Reduce the Quality!

As time goes by, technological developments along with tools resulting from innovation are becoming increasingly …

%d bloggers like this: