Link to home
Start Free TrialLog in
Avatar of dorinda
dorinda

asked on

Format an environment variable

I am using the following command in a bourne shell script: lic=`ps -ef|grep runcobol|wc -l|cut -c6-9`
It returns a numeric number, for example 14.  Is there a way to have it return the number as 4 digits zero filled? For example "0014"      
ASKER CERTIFIED SOLUTION
Avatar of ahoffmann
ahoffmann
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of bira
bira

lic=`ps -ef|grep runcobol|wc -l|cut -c6-9 |sed "s/ //g"`
a="000"
echo $a$lic |rev |cut -c1-4|rev