Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What can I do using awk that I cannot do in Perl?

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.

like image 679
alvin Avatar asked Apr 08 '10 19:04

alvin


People also ask

Is Perl better than awk?

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.

Can we use awk in Perl?

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.

What is awk good for?

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.

What is awk '{ print $2 }'?

awk '{ print $2; }' prints the second field of each line. This field happens to be the process ID from the ps aux output.


1 Answers

From perldoc perlvar:

Remember: the value of $/ is a string, not a regex. awk has to be better for something. :-)

like image 168
Eugene Yarmash Avatar answered Oct 23 '22 17:10

Eugene Yarmash