The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 01-03-2002
thangorn
Guest
  
 

Posts: n/a
Bits: 0 [Banking]
Smile Increminting a number

Hi

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 ??

Thanks