Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get rid of sed #3

Open
emreberge opened this issue Nov 25, 2011 · 0 comments
Open

Get rid of sed #3

emreberge opened this issue Nov 25, 2011 · 0 comments

Comments

@emreberge
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant