I want to rename all the files in a folder which starts with 123_xxx.txt
to xxx.txt
.
For example, my directory has:
123_xxx
you could check 'rename' tool
for example
rename 's/^123_//' *.txt
or (gawk is needed)
find . -name '123_*.txt'|awk '{print "mv "$0" "gensub(/\/123_(.*\.txt)$/,"/\\1","g");}'|sh
test:
kent$ tree
.
|-- 123_a.txt
|-- 123_b.txt
|-- 123_c.txt
|-- 123_d.txt
|-- 123_e.txt
`-- u
|-- 123_a.txt
|-- 123_b.txt
|-- 123_c.txt
|-- 123_d.txt
`-- 123_e.txt
1 directory, 10 files
kent$ find . -name '123_*.txt'|awk '{print "mv "$0" "gensub(/\/123_(.*\.txt)$/,"/\\1","g");}'|sh
kent$ tree
.
|-- a.txt
|-- b.txt
|-- c.txt
|-- d.txt
|-- e.txt
`-- u
|-- a.txt
|-- b.txt
|-- c.txt
|-- d.txt
`-- e.txt
1 directory, 10 files