May 14, 2002 #1 vaat MIS May 14, 2002 27 NL how do I display the fiels after the awk field search ? so je search for a string like: nawk '/string/ {print $1}' filename it is printing colomn 1 but I want the colomn after the string, that can be colomn 1,2,4,6,100 en so on ! alex
how do I display the fiels after the awk field search ? so je search for a string like: nawk '/string/ {print $1}' filename it is printing colomn 1 but I want the colomn after the string, that can be colomn 1,2,4,6,100 en so on ! alex
May 14, 2002 #2 bigoldbulldog Programmer Feb 26, 2002 286 US This sounds something like: /string/ { for( i = 1; i <= NF; i++ ) if( $i ~ /string/ ) print $(i+1) } Cheers, ND bigoldbulldog@hotmail.com Upvote 0 Downvote
This sounds something like: /string/ { for( i = 1; i <= NF; i++ ) if( $i ~ /string/ ) print $(i+1) } Cheers, ND bigoldbulldog@hotmail.com
May 17, 2002 Thread starter #3 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