Emacs, scripting and anything text oriented.

One liner if-else in awk

Kaushal Modi

Tiny snippets showing if/else use in awk ..

echo abc:def | awk -F: '{ if ( $2 ) {print $2} else {print} }'

Prints def.

echo abc | awk -F: '{ if ( $2 ) {print $2} else {print} }'

Prints abc.