Will awk be able to handle all my requirements?
I have been working with shell scripts (sh/csh/ksh) and I am able to do most of my administrative tasks using it. But sometimes I need some extra tools like awk to make my scripts more effective & convienient. These days I am learning awk, as I believe that combinedly shell & awk will make those scripts more powerful. But I am not sure that can I write scripts independently in awk? Will awk be able to fulfill all my requirements of day-to-day admin tasks (I hope all you Sys. admins & Unix engineers know what day-to-day tasks we do as a Unix admin).
So my questions is, shall I go with in-depth knowledge of awk and shall I spent time in learning in-depth of awk? I already know it little bit, so it will be easy for me to learn it.
On the other hand, I don't want to spent time in learning perl or python, as I dont have that much time these days to learn, write scripts & implement it in live environment.
Any suggestions are most welcome!
Yes you can invoke awk independently.
The more I use it, the more I like it and there are a lot of things I used to do with bash that I now do with awk (gnu awk or gawk, as shipped in Slackware). It certainly is easier and faster to learn IMHO than perl or python, especially with a shell scripting background.
The time you will spend to learn awk won't be lost.
As always, you need to choose the right tool for the right job, and that means knowing what the tools can and can't do.
awk is an advanced text processing language. If you do a lot of work extracting, editing, and reformatting text data from files or commands, then it will pay to learn how to use it. If, for example, you find yourself often chaining together strings of cut|grep|sed|etc., then they can generally be replaced with a single awk command. Stand-alone awk scripts can also often be used instead of combined shell+command scripts for text processing jobs (and will generally be more efficient in such cases).
But what awk isn't, is a general scripting tool. It won't replace the shell for things like file renaming or system maintenance. Although it does have a built-in ability to execute external commands, it's really more of a support feature for the main task of text processing, and isn't designed for general use.
So by all means do learn how to use awk. But don't think you need to dive deeply into it all at once. I suggest first taking enough time to learn what it can do, without worrying much about learning how to do it. Then you can decide how much time to put into studying it in detail. But in the end it's just another system tool, and the more familiar you are with it the more you'll be able to do with it.
Here are a few useful awk references:
The first one is probably the best for getting an overall view of the command.
BTW, another benefit of studying things like this is that the concepts you learn in one language very often translate over and help you in learning others as well. Much of awk syntax comes from C, which has also influenced many other languages and commands. I believe that learning awk has also improved my scripting ability in general.
Many thanks to David and Didier. I am going to learn it.. right now!
|All times are GMT -5. The time now is 10:29 PM.|