I have a bunch of database files in a directory. Their name are like:
1234_ABCD_01.dbf, 28hrs_ABCD_02.dbf
I want to change them in bulk to:
1234_XXXU_01.dbf, 28hrs_XXXU_02.dbf.
I mean I just want to replace ABCD by XXXU. don't change other part of the file name and the contents of the file. What is the best and easy way to do it. Please help me to figure out the Linux command or script. Thanks in advance.
Except that the solution would have problems taking care of files with white spaces..., if any. Its bad practice to use ls and pipe to while loop (extra overheads) to loop over files like that. Use shell expansion instead. eg
for file in *ABCD*...
do
....
done
Alternatively, if you have Ruby(1.9.1+), here's a one-liner