Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Format an environment variable

Posted on 2001-09-12
2
Medium Priority
?
273 Views
Last Modified: 2010-04-21
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"      
0
Comment
Question by:dorinda
2 Comments
 
LVL 51

Accepted Solution

by:
ahoffmann earned 400 total points
ID: 6477575
lic=`printf "%04d", $lic`
0
 
LVL 6

Expert Comment

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

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
In tuning file systems on the Solaris Operating System, changing some parameters of a file system usually destroys the data on it. For instance, changing the cache segment block size in the volume of a T3 requires that you delete the existing volu…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.
Suggested Courses
Course of the Month13 days, 11 hours left to enroll

963 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question