The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM



View Single Post in UNIX Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 08-24-2007
namishtiwari namishtiwari is offline
Registered User
 

Join Date: Aug 2007
Location: Bangalore
Posts: 288
Append 0 for single digit entered from command line

I have a script like this--

#!/bin/ksh
echo "To pad a 0 before digits from 1-9"
for i in $*
do
echo $i | sed 's/[1-9]/'0[1-9]'/g'
done

I run this script as

ksh name 1 2 23 34

The output should be
01 02 23 34

Help me in modifying this script.

Thanks
Namish
Reply With Quote
Remove advertisements
!!
Forum Sponsor