Linux Rename File Command

The mv command is used to rename files in Linux. The basic syntax is:

mv [existing_file_name] [new_file_name]

For example, to rename the file oldfile.txt to newfile.txt, you would run the following command:

mv oldfile.txt newfile.txt

Note that the mv command can also be used to move files from one directory to another. In this case, you would specify the full path to both the existing file and the destination directory, like this:

mv /path/to/existing_file /path/to/destination_directory/new_file_name

If you need to rename multiple files at once, you can use wildcard characters such as * and ? in the existing file names. For example:

mv oldfile_*.txt newfile_*.txt

This will rename all files that match the pattern oldfile_*.txt to newfile_*.txt.

Leave a Comment