awk question# Unix - 噫吁兮,危乎高哉
o*e
1 楼
I want to use awk to realize following goal:
when the line matches some Regular Expression, parsing
the line and output.
if the line doesn't match, don't make parsing and output
the original line.
I try to use if block like this:
if ( $0 ~ /expression/ )
{ printf "total energy =" ,$NF}
else
{printf $0}
But it doesn't work.
/expression/ {print "total energy =", $NF}
can find the desired line and output as I wish, but
I lose the control of other lines.
I don't know what's wrong with my cod
when the line matches some Regular Expression, parsing
the line and output.
if the line doesn't match, don't make parsing and output
the original line.
I try to use if block like this:
if ( $0 ~ /expression/ )
{ printf "total energy =" ,$NF}
else
{printf $0}
But it doesn't work.
/expression/ {print "total energy =", $NF}
can find the desired line and output as I wish, but
I lose the control of other lines.
I don't know what's wrong with my cod