Linux File RENAME Command

Source: Internet
Author: User

Renaming Linux Files is very simple. Common commands are mv commands and rename commands. The following describes the usage of these two commands. For details about the nodules, refer to the manual.

1. mv

MV fromfile tofile

For example, if the.txt file is named B .txt, it can be mv a.txt B .txt.

MV can only rename one file at a time, and it is a mobile command. If tofile already exists, it will directly overwrite the original file, resulting in file loss. Of course, there are options to prompt for existing files, but I mean, that option is really not commonly used. Based on these two considerations, let's take a look at rename.

2. Rename

Rename frompart topart filename or rename's/frompart/topart/'filename

If the.txt file is named B .txt, it can be rename 'A' B 'a.txt (this is the case if you haven't tried it and read what others have said on the Internet .) It can also be: Rename's/^ a/B/'a.txt

On some systems, you can use the previous sentence. On some systems, you can use the following sentence. There are two differences: one is C and the other is Perl. Obviously, the following is the regular expression. Which method can be used? Man rename is used to view the version on the last line of the manual page. Since the rename version of my system is Perl, I can only use this method later.

What makes rename powerful is that you can use *,? . When using music videos, you can only write scripts and solve them in a loop.

For more information about the two commands, see the online manual.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.