Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am decent with bash scripting and I am catching on to regex, and a little sed usage. Is learning awk still worth while with all the alternatives out there. Opinions?

share|improve this question
    
Worthwhile from what perspective? –  John Gardeniers Apr 29 '10 at 3:59

5 Answers 5

I use awk all the time and avoid writing or using perl as much as I can. Perl wanted to do too much and became a general purpose language but unfortunately has an horrible and unreadable syntax, IMHO. Maintaining perl scripts that have been written by someone else is a pain and this tend to be true for our own scripts after a while too.

On the other hand, awk has a limited but on purpose scope and works well with it. It interfaces relatively well with shell scripting too, unlike perl.

As for bash being a survivor, I prefer ksh93 if you ask me.

share|improve this answer
1  
+1 for using awk to avoid perl. –  TechZilla Aug 13 '12 at 14:23

It depends on your comfort level.

I came to the shell via perl, so I am comfortable with using perl for complicated things.

However I find that the longer I am doing this, I want to do more and more complicated things in shell one-liners rather than deal with the overhead of a "proper" perl script. I find awk an invaluable tool for doing complicated things.

It never hurts to learn a little of everything, even if it is just enough for you to figure out that this particular tool does not fit into your ways of doing things.

share|improve this answer

I would hardly call Perl "dying", whatever other opinions you may hold about it

Since you made the Awk vs. Perl comparison, you might be interested in looking at the book Minimal Perl. It shows how Perl compares to various Unix/Linux command line utilities. It should give you enough information to make a more informed decision about what to study, regardless of your choice.

Personally, I think there are better choices than Awk, and would only learn it if it was clearly the best choice for my task at hand. But then again, I could say the same about a lot of things...

share|improve this answer
3  
+1 for that first line. –  John Gardeniers Apr 29 '10 at 4:00

I still use awk occasionally - though I more frequently use Perl. If you don't want to learn Perl because you think it is dying (a view I disagree with, but you are entitled to your view), then consider Python instead. For plain text processing of columnar data, awk is excellent. For more general work, Perl or Python are excellent. After that, you are moving into heavy-duty systems programming and maybe C or C++ (or Go, or ...).

Bash is a very powerful shell. There are still things Perl can do that Bash can't. I still have to write code that will work other shells, so I have to be careful with what I use from the Bash feature set. Knowing it thoroughly will be good - but the other tools have their place too.

So, if you have the time to learn awk moderately well, or it is going to be easy for you because you are already adept at the components (extended regular expressions, C-like syntax), then it is an occasionally useful tool to have available to you. You might prefer to learn Perl or Python instead, though.

share|improve this answer

The different alternatives exist, not because each can do the same thing as the other (although this is true for localized cases, or for full programming languages such as Perl), but rather because they can do different things.

sed is not very suitable for processing tabular data, and using pure bash for that is usually more pain than one would like. awk operates almost trivially on tabular data, and can also be used to write smallish state machines. Spend some time looking at the various awk solutions on Stack Overflow for some ideas as to what it can do.

share|improve this answer
    
cool, thanks for your opinion –  Tom Dignan Apr 29 '10 at 2:36

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.