Linux 下rename 命令的用法第1/2頁

來源:互聯網
上載者:User

首先來說一下mv命令,在man mv中我們可以看到對於mv命令的介紹是這樣的:

mv -move(rename) files

可以看到mv命令確實有重新命名的功能,但是實際應用中,它只能對單個檔案重新命名,命令如下:

mv [path/]oldfilename [path/]newfilename

“mv命令只能對單個檔案重新命名”,這實就是mv命令和rename命令的在重新命名方面的根本區別。

再來說rename命令,在man rename的說明如下:

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 to.

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.

可以看出rename命令是專用於檔案重新命名的,而且根據其後的例子可以看出,rename除了給單個檔案重新命名,還可以批量檔案重新命名。同時,值得注意一點的是,rename命令是帶3個參數而不是很多人認為的2個參數。

上面的例子中給出了兩種檔案批量重新命名的用法,而實際上,rename結合萬用字元使用,它的功能比上面的例子所顯示的更強大。基本的萬用字元有以下幾個:

? 可替代單個字元

* 可替代多個字元

[charset] 可替代charset集中的任意單個字元

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.