Solved

Format an environment variable

Posted on 2001-09-12
2
260 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 51

Accepted Solution

by:
ahoffmann earned 100 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

Ready to get started with anonymous questions?

It's easy! Check out this step-by-step guide for asking an anonymous question on Experts Exchange.

Question has a verified solution.

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

Hello fellow BSD lovers, I've created a patch process for patching openjdk6 for BSD (FreeBSD specifically), although I tried to keep all BSD versions in mind when creating my patch. Welcome to OpenJDK6 on BSD First let me start with a little …
Installing FreeBSD… FreeBSD is a darling of an operating system. The stability and usability make it a clear choice for servers and desktops (for the cunning). Savvy?  The Ports collection makes available every popular FOSS application and packag…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

627 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