Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

AWK vs. Perl

Status
Not open for further replies.
Apr 13, 2004
316
US
There are times that I am trying to do something, as a Unix sys admin, and knowing the korn shell inside and out, it is the first tool I turn to. However, there are times that I need to do some things, which are more complex that ksh cannot do, or cannot do easily.

This is not to turn into a war of languages, but would I be better off becoming more proficient with AWK or Perl to complete these more complex tasks?

Keep in mind that I don’t want to – and am not going to - spend a great deal of time to become an expert with the language as I am with ksh, but want to be able to do more complex tasks with greater ease.
 
> but would I be better off becoming more proficient with AWK or Perl to complete these more complex tasks?
Yes.
It basically boils down to the more tools you have in your toolbox, the better able you are at tackling the jobs you have at present, and the wider the variety of jobs you can tackle in future.

> and am not going to - spend a great deal of time to become an expert with the language
I don't see that as a problem - I learnt AWK on a "as needed" basis, and I'm slowly learning PERL by the same method. Sure the programs aren't great programs compared to experienced programmers in those languages, but they get the job done for what I want them to do.

AWK is much simpler than PERL, and pretty much everything AWK can do, PERL can do in a similar manner. My suggestion would be to start with AWK.

Read through the book, try a few examples, but don't dwell on the subject for too long. You could even try applying some of the ideas to some of the "tricky" areas of some of your more recent ksh scripts, if what you're reading at that moment looks like it would have helped. Your aim here is to get a feel for what the language can do, not learn it outright from the beginning.

Later on, you won't remember how to do something, but you will remember that you saw something in the book which resembles your current problem and then you can go look for it. This is the "as needed" approach I mentioned earlier.

--
 
I'd agree with Salem in principle but if you are
truly expert in ksh many things in awk will just be
conveniences to you. Text processing and the like
can be done with only a little more effort in most
shells.
Perl is a much larger environment but it offers
you the capability to do many things in a more
concise and better designed (IMHO) way than similar
interfaces in (g)awk. It also offers the ability to
do many more things than are possible in (g)awk.
Not that I am a big fan of perl. far, far from
it. I'd use C or Tcl if I needed a more robust
or complicated solution.
 
I would learn PERL since it can do everything awk can do, and is somewhat endorsed in the Windows environment. Yes, I know there are free Unix utilies for Windows, but PERL seems to be taking over.

awk, however, is usually more efficient than perl, but I would be surprised if the execution time savings actually make a difference in anyone's environment.

Sometimes the grass is greener on the other side because there is more manure there - original.
 
Just looked at my most recent issue of Database Trends and Applications ( and noticed an article about "LAMP" architectures - an open source solution.

L = Linux
A = Apache Web Server
M = MySQL database
P = PHP/Python/Perl development languages

Another nod to perl IMHO.
- John

Sometimes the grass is greener on the other side because there is more manure there - original.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top