3 ms·
Is there any advantage (speed?) in using something like Awk over something like Python?
by new_test 14y ago
Is there any advantage (speed?) in using something like Awk over something like Python?
- ralph 14y agoIt's awkward to embed Python in a pipeline and the awk can be quicker to write if the problem suits its domain. Execution speed may be slower than Python, depends on the work needed and the awk used; gawk, mawk, Kernighan's One True awk, ... awk 'NR > 3 && !/foo/ {s += $(NF - 2)} END {print NR, s + 0}'
- npsimons 14y agoOpen up a terminal on Linux, OSX, or heck even Cygwin or MinGW on Windows. I'm willing to bet that awk is already pre-installed, even on a base or fresh install. Awk, like grep, sed and all the rest are pretty standard and very powerful. Not knocking Python, shell programming is just another paradigm, and the tools are pretty universally available.
- dredmorbius 14y agoAwk is part of the POSIX specification, so yes, it's going to be present on pretty much any Unix-like environment. Even those which don't aim at POSIX compliance will almost certainly have an awk interpreter. Busybox includes one, which means that many minimal / embedded systems will include awk by default (as they use busybox to provide core utilities).