Linux commands to modify file names include mv command, rename command, touch command, sed command, etc. Detailed introduction: 1. The mv command is used to rename files or directories, or move files from one directory to another. The syntax is "mv source file name target file name"; 2. The rename command is used to modify file names in batches. The syntax is "rename 'original file name' 'new file name' file list"; 3. touch command, etc.
#In Linux systems, there are a variety of commands that can be used to modify file names. The following are some commonly used commands:
mv 源文件名 目标文件名
For example, to rename a file named "file1.txt" to "file2.txt", you can use the following command:
mv file1.txt file2.txt
rename '原始文件名' '新文件名' 文件列表
For example, you want to rename the files named "file1.txt", "file2.txt" and "file3.txt" to "file1_new.txt" and "file2_new" respectively. .txt" and "file3_new.txt", you can use the following command:
rename 'file' 'file_new' file1.txt file2.txt file3.txt
touch -d 日期时间 文件名
For example, to modify the file named "file1.txt" to the current date and time, you can use the following command:
touch -d "$(date)" file1.txt
sed 's/原始文件名/新文件名/g' 文件列表 > 新文件列表
For example, you want to rename the files named "file1.txt", "file2.txt" and "file3.txt" to "file1_new.txt" and "file2_new" respectively. .txt" and "file3_new.txt", you can use the following commands:
sed 's/file/file_new/g' file1.txt file2.txt file3.txt > file1_new.txt file2_new.txt file3_new.txt
These commands can modify the file name to a certain extent. Which method to use depends on your needs and preferences.
The above is the detailed content of What are the commands to modify file names in Linux?. For more information, please follow other related articles on the PHP Chinese website!