awk help about show all the line beside the changed line

awk '/abc/{print $2}'

This will show the line contains abc and only show the "two filed"

But I want to the line contains "abc" will only show $2, other line still show.

and I want to know awk's way about not only show the line besides changed line

Thanks

if you show a sample file, a desired output and you're getting now, we might be able to help - reading the current 'explanation' is somewhat confusing....

1 Like
awk '{if ($0 ~ /abc/) print $2 ; else print}'
1 Like