I have a file named 35554842200284685106000166550020003504201637715423.xml
and I simply need to rename it to 42200284685106000166550020003504201637715423.xml
(remove everything before the last 48 characters). This simple regular expression (.{48}$
) can extract the last 48 characters, but I can't make it work using rename
in Bash.
How can I use rename
and this regular expression to rename it to only the last 48 characters?
Edit:
Output of rename --help
[root@ip-000-00-0-000 tmp]# rename --help
Usage:
rename [options] <expression> <replacement> <file>...
Rename files.
Options:
-v, --verbose explain what is being done
-s, --symlink act on the target of symlinks
-n, --no-act do not make any changes
-h, --help display this help and exit
-V, --version output version information and exit
For more details see rename(1).
Thank you.
rename
you're using - if you typerename
just by itself what error message does it give you? – Chris Davies Feb 24 '20 at 12:35rename 's/^.*(.{44}\.xml$)/$1/' 3*.xml
works perfectly here – Chris Davies Feb 24 '20 at 12:39rename
s are legion. In different distros they may be differently... named. :) – Kamil Maciorowski Feb 24 '20 at 12:43perl-rename
orprename
. By the way, please don't post images of text. Instead, paste the text directly into your question and use the formatting tools to format it as code. – terdon Feb 24 '20 at 13:06