Solved

Format an environment variable

Posted on 2001-09-12
2
238 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 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Let's say you need to move the data of a file system from one partition to another. This generally involves dismounting the file system, backing it up to tapes, and restoring it to a new partition. You may also copy the file system from one place to…
Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
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.

816 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now