3 ms·
Awk. Actually a full programming language but i usually use it for quick one liners: http://gregable.com/2010/09/why-you-should-know-just-little-awk.html http:
by gregable 15y ago
Awk. Actually a full programming language but i usually use it for quick one liners: http://gregable.com/2010/09/why-you-should-know-just-little-awk.html http://gregable.com/2010/09/why-you-should-know-just-little-...
- nikcub 15y agoevery developer should know sed and awk. it is amazing how many devs write cumbersome scripts or little programs to handle tasks that are built for sed and awk. my ~/bin folder has ~50 different little scripts that handle all sorts of small tasks.
- cop359 15y agoI don't really know a lot about this stuff, but my understanding is that Perl was more or less replaced sed and awk.
- caw 15y agoI code in Perl at my day job, and I still use awk and grep. Sometimes it's quicker to do it in awk than perl, especially when you're doing it in command line and have to figure out quotes. awk -F, '{print $3}' foo | xargs -I{} echo 'command -x -y -z {}' perl -e 'open F, "<foo"; while(<F>) { my($a,$b,$c,@rest) =split /,/; system("command -x -y -z $c"); }' I think I could do the split into an array and then take the third element, but I'm just trying to do an elementary example. When you want to do more things to this argument you necessarily have to grow this, and at one point I got to the point where I started having to escape quotes. That's rather difficult to read when you're just trying to do something quick in the command line and you mismatch a pair.
- ajays 15y agoInstead of opening the file "foo" by hand, you can use Perl's "awk mode" thusly: perl -lane 'system("command -x -y -z $F[2]")' foo
- brendano 15y agoawk (and to a lesser extent sed) is cleaner and easier to remember.