This question already has an answer here:
- Remove prefixes from filenames 2 answers
I have few files in the following directory:
-rwxr-xr-x. 1 root root 4430846 Apr 27 09:45 01-DSP-04.12_03_crc.bin -rwxr-xr-x. 1 root root 1659036 Apr 27 09:45 01-FL4-04.12_02-crc.bin -rwxr-xr-x. 1 root root 1659036 Apr 27 09:45 01-FL8-04.12_02-crc.bin -rwxr-xr-x. 1 root root 1659036 Apr 27 09:46 01-FPGA-04.12_02-crc.bin -rwxr-xr-x. 1 root root 524328 Apr 27 09:46 01-MMI-04.11_05-crc.bin -rwxr-xr-x. 1 root root 27692 Apr 27 09:46 01-PIC-04.11_06-crc.bin
Also, I have a script that does some work at
I want to remove the leading "01-" from the file names from this script. Is there any good way of doing this?
I tried the solution from https://stackoverflow.com/questions/28305134/remove-first-n-character-from-bunch-of-file-names-with-cut but do not work for me.
I get output like this:
$ for file in /var/lib/jenkins/bin/*; do echo mv $file `echo $file | cut -c4-`; done
mv /var/lib/jenkins/bin/01-DSP-04.12_03_crc.bin r/lib/jenkins/bin/01-DSP-04.12_03_crc.bin mv /var/lib/jenkins/bin/test.sh r/lib/jenkins/bin/test.sh
As you can see it removes first 3 character which is directory name, not file name. I want to remove 3 character after 21 character from file name.
Any better way to do this?