In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail how to rename files in linux. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.
Linux rename file method: 1, use mv command, syntax "mv old file name new file name"; 2, use rename command, syntax "rename old file name new file name".
The operating environment of this tutorial: CentOS 6 system, Dell G3 computer.
To rename a file or directory under Linux, you can use the mv command or the rename command. Here we share how to use both.
1. Use the mv command
The mv command can either rename or move files or folders.
Mv old file / directory new file name / directory
Example: rename directory A to B
Mv A B
Example: move the / a directory to / b and rename it to c
Mv / a / b/c
In fact, to rename a file or directory in text mode, you only need to use the mv command, for example, to rename a file named abc to 1234:
Mv abc 1234
Note that if there is also a 1234 file in the current directory, this file will overwrite it.
2. Use the rename command
The rename command changes the file name in batches with string substitution.
Rename a list of files
# rename main1.c to main.crename main1.c main.c main1.c
Rename supports wildcards
? Can replace a single character * can replace multiple characters [charset] can replace any single character in the charset set
There are these files in the folder foo1, … , foo9, foo10, , foo278
If you use rename foo foo0 foo?, to rename a foo1-to-foo9 file to foo01 to foo09, the renamed file is just a file with a four-character name, and the foo in the file name is replaced with foo0.
If all files that use rename foo foo0 foo??,foo01 to foo99 are renamed to foo001 to foo099, only files with five character names are renamed, and the foo in the file name is replaced with foo0.
If all files that use rename foo foo0 foo*,foo001 to foo278 are renamed foo0001 to foo0278, all files that start with foo are renamed.
If you use rename foo0 foo foo0 [2] *, all files from foo0200 to foo0278 are renamed foo200 to foo278, and the foo0 in the file name is replaced with foo.
Rename supports regular expressions
# replace AA in the file name with aarename "s/AA/aa/" * # change the .html suffix to the .php suffix rename "s//.html//.php/" * # all file names end in txt rename "s/$//.txt/" * # delete the .txt of all file names ending in .txt rename "s//.txt//" * about "how to repeat linux" That's all for the article named File. Hope that the above content can be helpful to you, so that you can learn more knowledge, if you think the article is good, please share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.