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/02 Report--
In this issue, I will bring you some information about how to rename files using rename command in Linux. The article is rich in content and analyzes and narrates from a professional perspective. After reading this article, I hope you can gain something.
The rename command is used to rename multiple files. This command is more advanced than mv because it requires some basic knowledge of regular expressions. It comes in two versions: the C version and the perl version; the syntax varies from version to version.
Here's how the perl version of rename is used. If this version of the rename command is not installed, it can be easily installed using the distribution's package manager.
Install rename command on Ubuntu and Debian
sudo apt install rename
Install rename command on CentOS and Fedora
sudo yum install prename
Install rename command on Arch Linux
yay perl-rename ## or yaourt -S perl-rename
Basic syntax for rename command:
rename [OPTIONS] perlexpr files
The rename command renames all files according to the specified plexpr regular expression.
Examples:
Change all files with.html extension to.php
rename 's/.html/.php/' *.html
You can use the-n parameter to print the names of files that need to be renamed without having to rename them.
rename -n 's/.html/.php/' *.html
The output looks like this:
rename(file-90.html, file-90.php)rename(file-91.html, file-91.php)rename(file-92.html, file-92.php)rename(file-93.html, file-93.php)rename(file-94.html, file-94.php)
By default, the rename command does not overwrite existing files; however, passing the-f argument allows existing files to be overwritten.
rename -f 's/.html/.php/' *.html
Common examples of using the rename command
Replace spaces in file names with underscores
rename 'y/ /_/' *
Convert file names to lowercase
rename 'y/A-Z/a-z/' *
Convert file names to uppercase
rename 'y/a-z/A-Z/' * The above is a small series for everyone to share how to rename files using the rename command in Linux? If you have similar doubts, you may wish to refer to the above analysis for understanding. If you want to know more about it, please pay attention to the industry information channel.
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.