Skip to content

Get rid of sed #3

@emreberge

Description

@emreberge

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions