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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help? How to remove starting white-space

Status
Not open for further replies.

g2345c

Technical User
Jun 23, 2004
22
US
#!/bin/sh
IP_ADDRESS=`/sbin/ifconfig | grep inet`
ex: the $IP_ADDRESS now is: " inet Ip: Mask:"

How do I remove the all the white-space at the begining of $IP_ADDRESS if any line before move on to the next statement? so that $IP_ADDRESS will become "inet Ip: Mask:"


thanks
 
/sbin/ifconfig -a | grep inet | sed "s/^$(/bin/echo '\t')//g"

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Have you tried this ?
t=`echo "\t\c"`
IP_ADDRESS=`/sbin/ifconfig | sed -n "/inet/s![^ $t]*!!p"`

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
PHV,
I think you meant:

IP_ADDRESS=`/sbin/ifconfig | sed -n "/inet/s!^[ $t]*!!p"`

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top