3 ms·
awk is a lot better at what it does than Python though, and much easier too. Even something simple as "cmd | awk {print $1}" in awk is something like: impor
by Beltalowda 5y ago
awk is a lot better at what it does than Python though, and much easier too.
Even something simple as "cmd | awk {print $1}" in awk is something like:
import sys, re
for line in sys.stdin.read().split('\n'):
s = re.split('\s+')
if len(s) > 0:
print(s[0])
else:
print()
And I probably got that incorrect as it's probably not the way to read stdin (it's been a while since I programmed Python).
I can list many gripes with Unix tools, but "awk bad" isn't on that list. It's a small language that solves a very specific problem, and does that surprisingly well. The syntax is about as simple as it gets – no idea how it's "terrible" or "impossible to remember", and it's certainly not "insane" as you seem to be suggesting.