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 -->
  #3 (permalink)  
Old 01-03-2002
LivinFree's Avatar
LivinFree LivinFree is offline Forum Advisor  
Goober Extraordinaire
  
 

Join Date: Jul 2001
Location: Portland, OR, USA
Posts: 1,584
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:
Code:
...
numcheck=$((`echo $num | wc -c` - 1))
until [ "$numcheck" = "4" ]; do
num="0${num}"
numcheck=$((`echo $num | wc -c` - 1))
done
rcfname=rfc${num}.txt
...
This may not be the best way to do it, but it works for my needs... Please post back if you want more help with this.

HTH