LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
LinkBack Search this Thread
Old 11-08-2012, 05:06 AM   #1
shivaa
Senior Member
 
Registered: Jul 2012
Location: Grenoble, Fr.
Distribution: Sun Solaris, RHEL, Ubuntu, Debian 6.0
Posts: 1,778
Blog Entries: 4

Rep: Reputation: 282Reputation: 282Reputation: 282
Will awk be able to handle all my requirements?


Hello friends!
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!

Last edited by shivaa; 11-08-2012 at 05:11 AM.
 
Old 11-08-2012, 05:40 AM   #2
Didier Spaier
Senior Member
 
Registered: Nov 2008
Location: Paris, France
Distribution: Slackware-14.0 on a Lenovo T61 6457-4XG
Posts: 3,666

Rep: Reputation: 828Reputation: 828Reputation: 828Reputation: 828Reputation: 828Reputation: 828Reputation: 828
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.

Last edited by Didier Spaier; 11-08-2012 at 05:49 AM.
 
1 members found this post helpful.
Old 11-08-2012, 01:31 PM   #3
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946
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:
http://www.grymoire.com/Unix/Awk.html
http://www.gnu.org/software/gawk/man...ode/index.html
http://www.pement.org/awk/awk1line.txt
http://www.catonmat.net/blog/awk-one...ined-part-one/

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.
 
1 members found this post helpful.
Old 11-08-2012, 08:17 PM   #4
shivaa
Senior Member
 
Registered: Jul 2012
Location: Grenoble, Fr.
Distribution: Sun Solaris, RHEL, Ubuntu, Debian 6.0
Posts: 1,778
Blog Entries: 4

Original Poster
Rep: Reputation: 282Reputation: 282Reputation: 282
Many thanks to David and Didier. I am going to learn it.. right now!
 
  


Reply

Tags
awk


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how many files can awk handle at a time? iconig Linux - Newbie 4 08-03-2012 11:59 AM
awk return an error that I don't know how to handle coss_cat Linux - Software 3 12-09-2011 10:15 AM
how to handle division by zero in awk dazdaz Programming 2 05-29-2011 07:15 PM
[SOLVED] call awk from bash script behaves differently to awk from CLI = missing newlines titanium_geek Programming 4 05-26-2011 09:06 PM
Limit in number of fields that awk can handle ? chargaff Programming 4 03-03-2011 08:36 AM


All times are GMT -5. The time now is 02:39 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration