3 ms·
awk is amazing. One pattern I often use is: $ query_something | awk 'generate commands' | sh For larger programs, I wrote and use ngetopt.awk: https://github.
by joepvd 4y ago
awk is amazing. One pattern I often use is:
$ query_something | awk 'generate commands' | sh
For larger programs, I wrote and use ngetopt.awk: https://github.com/joepvd/ngetopt.awk https://github.com/joepvd/ngetopt.awk. This is a loadable library for gawk that lets you add option parsing for programs.
- mturmon 4y agoThis can be a very powerful idiom (basically, code generation at the shell prompt). It’s well suited to iterative composition of the commands: I’ll write the query/find part, and (with ctrl P) add the awk manipulations, and then pipe to sh. If it doesn’t have side effects you can pass through “head” before “sh” to check syntax on a subset.