MyTetra Share
Делитесь знаниями!
Linux Rename File Command
Время создания: 05.09.2017 09:36
Текстовые метки: linux cli rename
Раздел: Linux
Запись: Velonski/mytetra-database/master/base/1504586189jz1rsk3gx4/text.html на raw.githubusercontent.com

To rename multiple files use rename command or script provided by MySQL/MariaDB package as per regex.

How to rename a file Linux?

The syntax is as follows:
mv old-file-name new-file-name
mv [options] old-file-name new-file-name
mv file1 file2

Examples: Renaming files with mv Command

In this example, rename a file called resumezzz.pdf to resume.pdf. Open a command-line terminal (select Applications > Accessories > Terminal), and then type:
mv resumezzz.pdf resume.pdf
If resumezzz.pdf is located in /home/vivek/docs/files directory, type:
cd /home/vivek/docs/files
mv resumezzz.pdf resume.pdf
OR
mv /home/vivek/docs/files/resumezzz.pdf /home/vivek/docs/files/resume.pdf
Use the ls command to view files:
ls -l file1
ls -l file1 file2
ls -l /home/vivek/docs/files/*.pdf
ls -l *.pdf

Linux rename a file syntax

In short, to rename a file:
mv file1 file2
You can get verbose output i.e. mv command can explain what is being done using the following syntax:
mv -v file1 file2
Sample outputs:

`file1' -> `file2'

To make mv interactive pass the -i option. This option will prompt before overwriting file and recommended for new users:
mv -i file1 file2
Sample outputs:

mv: overwrite `file2'? y

How to use rename command to renames multiple files

The syntax is:
rename 's/old/new/' files
rename [options] 's/old/new/' files
For example, rename all perl files (*.perl) to *.pl, enter:
rename 's/perl/pl/' *.perl
OR
rename -v 's/perl/pl/' *.perl
Sample outputs:

'bar.perl' renamed to 'bar.pl'

'foo.perl' renamed to 'foo.pl'

'input.perl' renamed to 'input.pl'

'output.perl' renamed to 'output.pl'

'test.perl' renamed to 'test.pl'

The above command changed all files with the extension .perl to .pl. See “Howto Rename Multiple Files At a Shell Prompt In Linux or Unix” for more info.

Detailed information about mv command

You can also view the manual page on mv using the following command:
man mv
OR
info mv
OR
man rename

Так же в этом разделе:
 
MyTetra Share v.0.65
Яндекс индекс цитирования