May 14, 2002 #1 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 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 ?
May 14, 2002 #2 bigoldbulldog Programmer Feb 26, 2002 286 US How about using sub nawk -F, '/--/ {sub(/^[ \t]*/,$1);print $1, FS, $2}' filename Cheers, ND bigoldbulldog@hotmail.com Upvote 0 Downvote
How about using sub nawk -F, '/--/ {sub(/^[ \t]*/,$1);print $1, FS, $2}' filename Cheers, ND bigoldbulldog@hotmail.com
May 15, 2002 Thread starter #3 vaat MIS May 14, 2002 27 NL Sorry, but this doesn't work ! alex Upvote 0 Downvote
May 15, 2002 #4 vgersh99 Programmer Jul 27, 2000 2,146 US pls post your sample file vlad Upvote 0 Downvote
May 17, 2002 Thread starter #5 vaat MIS May 14, 2002 27 NL 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 Upvote 0 Downvote
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