im creating lots of log files, Im writing a script to number them and scp them to a remote server,
the files need to be called 0001.log 0002.log etc etc
in my script I made a counter variable
$counter=00001
I tried adding a number to the variable like this
$counter=`echo "$counter + 1" | bc`
but this gives me 2 not 0002
i tried with perl also $counter++
does anyone know a simple way to imrement but keep the leding 0's ??
I keep a list of all RFC's on my workstation for some idle reading, and use a script to diplay a topic for the number I supply. The format they're in is: rfc####.txt, where the extra spaces are padded by "0"'s. I came up with this simple little routine to pad the left side of the number with zero's until I get a total of 4 characters: