Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delete one character in the front of a variable 1

Status
Not open for further replies.

pho01

Programmer
Mar 17, 2003
218
US
In a shell script, I used cat, grep and cut to get a number out of a log file.

INCIDENTNUM=`cat $LOGFILE | grep "INCIDENT NUMBER" | cut -d";" -f 2`

INCIDENTNUM returns " 23"
How do I delete an space char in the front so it reads "23" instead of " 23"?
Thanks,
 
You could pipe it to sed. eg:
Code:
INCIDENTNUM=` ... | sed -e 's/^  *//`
 
Try something like this:
Code:
INCIDENTNUM=`awk -F";" '/INCIDENT NUMBER/{printf "%d",$2}'`

Hope This Help
PH.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top