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

removing leiding spaces

Status
Not open for further replies.

vaat

MIS
May 14, 2002
27
NL
How can I remove leiding spaces in the print format ?

I do something like:

nawk -F, '/--/ {print $1, FS, $2}' filename

and get a line something like this:

-- bla bla bla

so how do I remove the leiding spaces ?

 
How about using sub

nawk -F, '/--/ {sub(/^[ \t]*/,$1);print $1, FS, $2}' filename

Cheers,
ND [smile]

bigoldbulldog@hotmail.com
 
this works : thanxs all !!!

for i in `ls startrek*`
do
echo $i
sp=`nawk '!/--/ && !/stardate/ {print $0}' $i`;
cr=`nawk -F, '/--/ {print $1, $2}' $i`;
st=`nawk -F "stardate" '/stardate/ {print $2}' $i`;
echo $st @ $cr @ $sp >> bla
done

sort -fi bla | nawk -F@ '{printf "STARDATE\t %s\n CREDITS\t %s\n SPREUK\t\t %s\n\n", $1, $2, $3}' > uitvoer
rm bla


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top