2006-12-06 17:25:41 -06:00
|
|
|
.\" Written by Andries E. Brouwer (aeb@cwi.nl)
|
|
|
|
.\" Placed in the public domain
|
|
|
|
.\"
|
2011-08-18 15:18:34 -05:00
|
|
|
.TH RENAME 1 "June 2011" "util-linux" "User Commands"
|
2006-12-06 17:25:41 -06:00
|
|
|
.SH NAME
|
2011-02-27 09:28:14 -06:00
|
|
|
rename \- rename files
|
2006-12-06 17:25:41 -06:00
|
|
|
.SH SYNOPSIS
|
2009-07-22 04:29:04 -05:00
|
|
|
.B rename
|
2014-12-14 13:45:29 -06:00
|
|
|
[options]
|
|
|
|
.IR "expression replacement file" ...
|
2006-12-06 17:25:41 -06:00
|
|
|
.SH DESCRIPTION
|
|
|
|
.B rename
|
|
|
|
will rename the specified files by replacing the first occurrence of
|
2011-06-11 16:42:45 -05:00
|
|
|
.I expression
|
2006-12-06 17:25:41 -06:00
|
|
|
in their name by
|
2011-06-11 16:42:45 -05:00
|
|
|
.IR replacement .
|
|
|
|
.SH OPTIONS
|
2007-09-04 02:33:36 -05:00
|
|
|
.TP
|
2014-12-14 13:45:31 -06:00
|
|
|
.BR \-s , " \-\-symlink"
|
|
|
|
Do not rename a symlink but its target.
|
2011-06-11 16:42:45 -05:00
|
|
|
.TP
|
2014-12-14 13:45:31 -06:00
|
|
|
.BR \-v , " \-\-verbose"
|
2017-12-23 15:44:34 -06:00
|
|
|
Show which files were renamed, if any.
|
2011-06-11 16:42:45 -05:00
|
|
|
.TP
|
2017-06-06 05:09:34 -05:00
|
|
|
.BR \-n , " \-\-no\-act"
|
2018-03-29 05:58:44 -05:00
|
|
|
Do not make any changes; add
|
2018-05-18 14:21:42 -05:00
|
|
|
.B \-\-verbose
|
2018-03-29 05:58:44 -05:00
|
|
|
to see what would be made.
|
2017-02-13 06:44:38 -06:00
|
|
|
.TP
|
2017-06-06 05:09:34 -05:00
|
|
|
.BR \-o , " \-\-no\-overwrite"
|
2018-03-24 17:53:21 -05:00
|
|
|
Do not overwrite existing files. When
|
2018-05-18 14:21:42 -05:00
|
|
|
.B \-\-symlink
|
2018-03-24 17:53:21 -05:00
|
|
|
is active, do not overwrite symlinks pointing to existing targets.
|
2017-06-06 05:09:34 -05:00
|
|
|
.TP
|
2018-03-24 06:15:55 -05:00
|
|
|
.BR \-i , " \-\-interactive"
|
|
|
|
Ask before overwriting existing files.
|
|
|
|
.TP
|
2014-12-14 13:45:31 -06:00
|
|
|
.BR \-V , " \-\-version"
|
|
|
|
Display version information and exit.
|
2012-11-26 09:50:08 -06:00
|
|
|
.TP
|
2014-12-14 13:45:31 -06:00
|
|
|
.BR \-h , " \-\-help"
|
2011-08-28 04:14:42 -05:00
|
|
|
Display help text and exit.
|
2011-06-11 16:42:45 -05:00
|
|
|
.SH WARNING
|
2018-03-24 06:20:58 -05:00
|
|
|
The renaming has no safeguards by default or without any one of the options
|
|
|
|
.B \-\-no-overwrite\fR,
|
|
|
|
.B \-\-interactive
|
|
|
|
or
|
|
|
|
.B \-\-no\-act\fR.
|
|
|
|
If the user has
|
2017-02-13 06:44:38 -06:00
|
|
|
permission to rewrite file names, the command will perform the action without
|
|
|
|
any questions. For example, the result can be quite drastic when the command
|
|
|
|
is run as root in the /lib directory. Always make a backup before running the
|
|
|
|
command, unless you truly know what you are doing.
|
2018-04-02 08:32:44 -05:00
|
|
|
.SH INTERACTIVE MODE
|
|
|
|
As most standard utilities rename can be used with a terminal device (tty in
|
|
|
|
short) in canonical mode, where the line is buffered by the tty and you press
|
|
|
|
ENTER to validate the user input. If you put your tty in cbreak mode however,
|
|
|
|
rename requires only a single key press to answer the prompt. To set cbreak
|
|
|
|
mode, run for example:
|
|
|
|
.PP
|
2020-06-10 18:57:22 -05:00
|
|
|
.RS
|
2018-04-02 08:32:44 -05:00
|
|
|
.nf
|
2019-12-15 18:51:57 -06:00
|
|
|
sh \-c 'stty \-icanon min 1; "$0" "$@"; stty icanon' rename \-i from to files
|
2018-04-02 08:32:44 -05:00
|
|
|
.fi
|
|
|
|
.RE
|
2020-05-19 03:31:19 -05:00
|
|
|
.SH EXIT STATUS
|
2014-06-28 12:42:49 -05:00
|
|
|
.RS
|
|
|
|
.PD 0
|
|
|
|
.TP
|
|
|
|
.B 0
|
|
|
|
all requested rename operations were successful
|
|
|
|
.TP
|
|
|
|
.B 1
|
|
|
|
all rename operations failed
|
|
|
|
.TP
|
|
|
|
.B 2
|
|
|
|
some rename operations failed
|
|
|
|
.TP
|
|
|
|
.B 4
|
|
|
|
nothing was renamed
|
|
|
|
.TP
|
|
|
|
.B 64
|
|
|
|
unanticipated error occurred
|
|
|
|
.PD
|
|
|
|
.RE
|
2020-05-25 07:59:12 -05:00
|
|
|
.SH EXAMPLES
|
Manual pages: order NOTES / HISTORY / BUGS / EXAMPLE consistently
There is value in ensuring that manual page sections use consistently
named sections, as far as possible, and also that sections have a
consistent order within manual pages. This is one of a series of patches
to place manual page sections in a consistent order.
In this patch, we ensure that the NOTES, HISTORY, BUGS, and EXAMPLE
sections are always placed near the end of the page, just above
AUTHORS, COPYRIGHT, SEE ALSO, and AVAILABILITY.
One page is not fixed by this patch: term-utils/agetty.8. This page
is a mess of unusual section names, and probably requires an individual
edit.
Testing that no gross editing mistake (causing accidental loss or addition
of text) was performed as follows:
$ cat $(grep '\.SH' -l $(find . -name '*.[1-9]') |sort) | sort > a
[Apply patch]
$ cat $(grep '\.SH' -l $(find . -name '*.[1-9]') |sort) | sort > b
$ diff a b
$ echo $?
0
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-05-21 02:28:32 -05:00
|
|
|
Given the files
|
|
|
|
.IR foo1 ", ..., " foo9 ", " foo10 ", ..., " foo278 ,
|
|
|
|
the commands
|
|
|
|
.PP
|
2020-06-10 18:57:22 -05:00
|
|
|
.RS
|
Manual pages: order NOTES / HISTORY / BUGS / EXAMPLE consistently
There is value in ensuring that manual page sections use consistently
named sections, as far as possible, and also that sections have a
consistent order within manual pages. This is one of a series of patches
to place manual page sections in a consistent order.
In this patch, we ensure that the NOTES, HISTORY, BUGS, and EXAMPLE
sections are always placed near the end of the page, just above
AUTHORS, COPYRIGHT, SEE ALSO, and AVAILABILITY.
One page is not fixed by this patch: term-utils/agetty.8. This page
is a mess of unusual section names, and probably requires an individual
edit.
Testing that no gross editing mistake (causing accidental loss or addition
of text) was performed as follows:
$ cat $(grep '\.SH' -l $(find . -name '*.[1-9]') |sort) | sort > a
[Apply patch]
$ cat $(grep '\.SH' -l $(find . -name '*.[1-9]') |sort) | sort > b
$ diff a b
$ echo $?
0
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-05-21 02:28:32 -05:00
|
|
|
.nf
|
|
|
|
rename foo foo00 foo?
|
|
|
|
rename foo foo0 foo??
|
|
|
|
.fi
|
|
|
|
.RE
|
2020-06-10 18:57:22 -05:00
|
|
|
.PP
|
Manual pages: order NOTES / HISTORY / BUGS / EXAMPLE consistently
There is value in ensuring that manual page sections use consistently
named sections, as far as possible, and also that sections have a
consistent order within manual pages. This is one of a series of patches
to place manual page sections in a consistent order.
In this patch, we ensure that the NOTES, HISTORY, BUGS, and EXAMPLE
sections are always placed near the end of the page, just above
AUTHORS, COPYRIGHT, SEE ALSO, and AVAILABILITY.
One page is not fixed by this patch: term-utils/agetty.8. This page
is a mess of unusual section names, and probably requires an individual
edit.
Testing that no gross editing mistake (causing accidental loss or addition
of text) was performed as follows:
$ cat $(grep '\.SH' -l $(find . -name '*.[1-9]') |sort) | sort > a
[Apply patch]
$ cat $(grep '\.SH' -l $(find . -name '*.[1-9]') |sort) | sort > b
$ diff a b
$ echo $?
0
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-05-21 02:28:32 -05:00
|
|
|
will turn them into
|
|
|
|
.IR foo001 ", ..., " foo009 ", " foo010 ", ..., " foo278 .
|
|
|
|
And
|
|
|
|
.PP
|
2020-06-10 18:57:22 -05:00
|
|
|
.RS
|
Manual pages: order NOTES / HISTORY / BUGS / EXAMPLE consistently
There is value in ensuring that manual page sections use consistently
named sections, as far as possible, and also that sections have a
consistent order within manual pages. This is one of a series of patches
to place manual page sections in a consistent order.
In this patch, we ensure that the NOTES, HISTORY, BUGS, and EXAMPLE
sections are always placed near the end of the page, just above
AUTHORS, COPYRIGHT, SEE ALSO, and AVAILABILITY.
One page is not fixed by this patch: term-utils/agetty.8. This page
is a mess of unusual section names, and probably requires an individual
edit.
Testing that no gross editing mistake (causing accidental loss or addition
of text) was performed as follows:
$ cat $(grep '\.SH' -l $(find . -name '*.[1-9]') |sort) | sort > a
[Apply patch]
$ cat $(grep '\.SH' -l $(find . -name '*.[1-9]') |sort) | sort > b
$ diff a b
$ echo $?
0
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-05-21 02:28:32 -05:00
|
|
|
.nf
|
|
|
|
rename .htm .html *.htm
|
|
|
|
.fi
|
|
|
|
.RE
|
2020-06-10 18:57:22 -05:00
|
|
|
.PP
|
Manual pages: order NOTES / HISTORY / BUGS / EXAMPLE consistently
There is value in ensuring that manual page sections use consistently
named sections, as far as possible, and also that sections have a
consistent order within manual pages. This is one of a series of patches
to place manual page sections in a consistent order.
In this patch, we ensure that the NOTES, HISTORY, BUGS, and EXAMPLE
sections are always placed near the end of the page, just above
AUTHORS, COPYRIGHT, SEE ALSO, and AVAILABILITY.
One page is not fixed by this patch: term-utils/agetty.8. This page
is a mess of unusual section names, and probably requires an individual
edit.
Testing that no gross editing mistake (causing accidental loss or addition
of text) was performed as follows:
$ cat $(grep '\.SH' -l $(find . -name '*.[1-9]') |sort) | sort > a
[Apply patch]
$ cat $(grep '\.SH' -l $(find . -name '*.[1-9]') |sort) | sort > b
$ diff a b
$ echo $?
0
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-05-21 02:28:32 -05:00
|
|
|
will fix the extension of your html files.
|
|
|
|
Provide an empty string for shortening:
|
|
|
|
.PP
|
2020-06-10 18:57:22 -05:00
|
|
|
.RS
|
Manual pages: order NOTES / HISTORY / BUGS / EXAMPLE consistently
There is value in ensuring that manual page sections use consistently
named sections, as far as possible, and also that sections have a
consistent order within manual pages. This is one of a series of patches
to place manual page sections in a consistent order.
In this patch, we ensure that the NOTES, HISTORY, BUGS, and EXAMPLE
sections are always placed near the end of the page, just above
AUTHORS, COPYRIGHT, SEE ALSO, and AVAILABILITY.
One page is not fixed by this patch: term-utils/agetty.8. This page
is a mess of unusual section names, and probably requires an individual
edit.
Testing that no gross editing mistake (causing accidental loss or addition
of text) was performed as follows:
$ cat $(grep '\.SH' -l $(find . -name '*.[1-9]') |sort) | sort > a
[Apply patch]
$ cat $(grep '\.SH' -l $(find . -name '*.[1-9]') |sort) | sort > b
$ diff a b
$ echo $?
0
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-05-21 02:28:32 -05:00
|
|
|
.nf
|
|
|
|
rename '_with_long_name' '' file_with_long_name.*
|
|
|
|
.fi
|
|
|
|
.RE
|
2020-06-10 18:57:22 -05:00
|
|
|
.PP
|
Manual pages: order NOTES / HISTORY / BUGS / EXAMPLE consistently
There is value in ensuring that manual page sections use consistently
named sections, as far as possible, and also that sections have a
consistent order within manual pages. This is one of a series of patches
to place manual page sections in a consistent order.
In this patch, we ensure that the NOTES, HISTORY, BUGS, and EXAMPLE
sections are always placed near the end of the page, just above
AUTHORS, COPYRIGHT, SEE ALSO, and AVAILABILITY.
One page is not fixed by this patch: term-utils/agetty.8. This page
is a mess of unusual section names, and probably requires an individual
edit.
Testing that no gross editing mistake (causing accidental loss or addition
of text) was performed as follows:
$ cat $(grep '\.SH' -l $(find . -name '*.[1-9]') |sort) | sort > a
[Apply patch]
$ cat $(grep '\.SH' -l $(find . -name '*.[1-9]') |sort) | sort > b
$ diff a b
$ echo $?
0
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-05-21 02:28:32 -05:00
|
|
|
will remove the substring in the filenames.
|
2020-05-19 03:31:19 -05:00
|
|
|
.SH SEE ALSO
|
2006-12-06 17:25:41 -06:00
|
|
|
.BR mv (1)
|
2007-07-02 18:17:04 -05:00
|
|
|
.SH AVAILABILITY
|
2010-11-30 04:41:59 -06:00
|
|
|
The rename command is part of the util-linux package and is available from
|
2016-12-17 02:06:57 -06:00
|
|
|
https://www.kernel.org/pub/linux/utils/util-linux/.
|