splunk/splunk-app-splunkgit — Issue #3: Get rid of sed
Author: emreberge
Created: 2011-11-25 22:15:41+00:00
State: open

Use the filtering built in to awk instead.

$> cat file.txt | sed '/^$/d'

can be done as:

$> cat file.txt | awk '$0!~/^$/ {print $0}'
(i.e. if the whole line is not empty, print the whole line)

That way you can get rid of sed, and put the whole awk program into a file, add any additional conditions for which lines to care about or ignore, format the code nicely and use it as an arg to awk:

$> cat file.txt | awk -f print_non-empty_lines.awk

Thankyou robinsp for pointing it out