Add leading zero's
by GPGAgent from LinuxQuestions.org on (#54VJ2)
I have a simple bash script
Code:#!/bin/bash
COUNTER=0;
for FF in *.MP2
do ((COUNTER++));
FFF=Ep$COUNTER.MP2
echo $FFF
done;That produces this
Code:charlie@charlie-machine:~/MP2-MP3/Test/LATEST/ThePrisoner$ ls
05241758.MP2 05311758.MP2 06071758.MP2 06141759.MP2 .....12 FILES
charlie@charlie-machine:~/MP2-MP3/Test/LATEST/ThePrisoner$ ./ProcessEpisodes.sh
18904 (process ID) old priority 0, new priority 19
Ep1.MP2
Ep2.MP2
Ep3.MP2
Ep4.MP2
Ep5.MP2
Ep6.MP2
Ep7.MP2
Ep8.MP2
Ep9.MP2
Ep10.MP2
Ep11.MP2
Ep12.MP2
charlie@charlie-machine:~/MP2-MP3/Test/LATEST/ThePrisoner$I want to add a leading zero to the output
Code:Ep01.MP2
Ep02.MP2
Ep03.MP2
Ep04.MP2
Ep05.MP2
Ep06.MP2
Ep07.MP2
Ep08.MP2
Ep09.MP2
Ep10.MP2
Ep11.MP2
Ep12.MP2It looks like it should be easy, but ........


Code:#!/bin/bash
COUNTER=0;
for FF in *.MP2
do ((COUNTER++));
FFF=Ep$COUNTER.MP2
echo $FFF
done;That produces this
Code:charlie@charlie-machine:~/MP2-MP3/Test/LATEST/ThePrisoner$ ls
05241758.MP2 05311758.MP2 06071758.MP2 06141759.MP2 .....12 FILES
charlie@charlie-machine:~/MP2-MP3/Test/LATEST/ThePrisoner$ ./ProcessEpisodes.sh
18904 (process ID) old priority 0, new priority 19
Ep1.MP2
Ep2.MP2
Ep3.MP2
Ep4.MP2
Ep5.MP2
Ep6.MP2
Ep7.MP2
Ep8.MP2
Ep9.MP2
Ep10.MP2
Ep11.MP2
Ep12.MP2
charlie@charlie-machine:~/MP2-MP3/Test/LATEST/ThePrisoner$I want to add a leading zero to the output
Code:Ep01.MP2
Ep02.MP2
Ep03.MP2
Ep04.MP2
Ep05.MP2
Ep06.MP2
Ep07.MP2
Ep08.MP2
Ep09.MP2
Ep10.MP2
Ep11.MP2
Ep12.MP2It looks like it should be easy, but ........