SHADE-AI / daidepp

Repo to store universal communication specification
2 stars 7 forks source link

Ci/38 replace grep with pattern in awk programs #71

Closed bpshaver closed 1 year ago

bpshaver commented 1 year ago

Ben read the first fews of the AWK book

bpshaver commented 1 year ago

I don't know awk so just gonna say this looks good

The general form of an awk invocation is

awk 'program' file

or you can pipe input to it. Or it can receive from stdin.

an AWK program contains one or more lines like

pattern { action }

where one or both of a pattern and an action can be supplied.

AWK splits lines in whitespace by default, so you could print every 3rd field where the second field is above zero like this:

awk ' $2 > 0 { print $3 } ' input.txt

Basically, a lot of people grep then pass things to AWK because they only know about the { action } part but not the pattern part.