[Shell] sed + mv + for renaming

1. Use a command to all under / home / a / directory "abc" at the beginning and end of the .txt file name of the file, change to the beginning of 123. Such as: abcdefg.txt, abc345.txt were renamed 123defg.txt 123345.txt

answer:

for e in `ls /home/a/ | grep p*d`;do; mv $e `echo $e|sed ‘s/p/123/’`; done

 

Guess you like

Origin blog.csdn.net/zkq_1986/article/details/92078505