Page 1/2 of RENAME command usage in Linux

Source: Internet
Author: User

First, let's take a look at the MV command. In man mV, we can see that the introduction to the MV command is as follows:

MV-move (rename) files

You can see that the MV command does have the rename function, but in actual applications, it can only rename a single file. The command is as follows:

MV [path/] oldfilename [path/] newfilename

The MV command can only rename a single file. This is the fundamental difference between the MV command and the RENAME Command in renaming.

The RENAME command describes man Rename as follows:

Name

Rename-rename files

Synopsis

Rename from to file ....

Description

Rename will rename the specified files by replacing the first occurrence of from in their name by.

For example, given the files foo1,..., foo9, foo10,..., foo278, the commands

Rename Foo foo0 Foo?

Rename Foo foo0 Foo ??

Will turn them into foo001,..., foo009, foo010,..., foo278.

And

Rename. htm. html *. htm

Will fix the extension of your HTML files.

It can be seen that the RENAME Command is dedicated to file rename. According to the following example, rename can be used to rename a single file in batches. At the same time, it is worth noting that the RENAME command contains three parameters instead of the two parameters that many people think.

In the above example, the use of batch Rename for two types of files is given. In fact, rename is used in combination with wildcards, and its function is more powerful than that shown in the above example. Basic wildcards include the following:

? Can replace a single character

* Replace multiple characters

[Charset] can replace any single character in the charset set

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.