I had read somewhere about one specific feature that is present in awk
but not in Perl. I have failed in locating it again.
I would appreciate it if anyone here can point it out.
This might be a useless trivia, but I am still curious to know.
Awk - when you only need simple formatting and summarisation or transformation of data. Perl - for almost any task, but especially when the task needs complex regular expressions. Python - for the same tasks that you could use Perl for.
in Perl. If you have an existing awk program, and wish it to run with Perl, you can perform a mechanical translation using the a2p utility provided with the Perl distribution. This utility converts the awk syntax into the Perl syntax, and for the vast majority of awk programs, provides a directly runnable Perl script.
Awk is a utility that enables a programmer to write tiny but effective programs in the form of statements that define text patterns that are to be searched for in each line of a document and the action that is to be taken when a match is found within a line. Awk is mostly used for pattern scanning and processing.
awk '{ print $2; }' prints the second field of each line. This field happens to be the process ID from the ps aux output.
From perldoc perlvar:
Remember: the value of
$/
is a string, not a regex.awk
has to be better for something. :-)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With