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.

If you have written a response to this, enter your response post's URL below.

Or, you can send a "comment" webmention (it's OK if you don't know what that means). When asked about your website on an IndieAuth login screen, simply type https://commentpara.de.

Markdown Support**bold**, _italics_, ~~strikethrough~~, [descr](link), `monospace`, ```LANG\nline1\nline2\n``` (Yep, multi-line code blocks too, with syntax highlighting!), auto-hyperlinking.

Webmentions #