Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 04-08-2007, 12:43 AM   #1
LQ Newbie
Registered: Mar 2007
Posts: 21

Rep: Reputation: 15
Lightbulb the 'awk' command.

I have enrolled in a Linux Certification course and damn this particular book for not being more specific about commands than to give the jist. I wondered if someone might tell me what a "delimiter" is when used in reference to the 'awk' command. An example of usage is:
ls filename | awk -->-F:<-- '/and/{print $2,$6,$9}
where the -F argument is used to change the delimiter from the default, tabs and spaces, to the configuration common delimiter of colon, :.
Also, I wondered, because the book is unclear in its explanation of the 'awk' command if the ' is an argument to say "search" or what exactly does the apostrophe denote to this command?
An example usage is:
ls filename | awk -->'<--/and/{$1}

In either example the arrows point to the appropriate argument/modifier. Thankyou.

Old 04-08-2007, 12:50 AM   #2
Senior Member
Registered: Feb 2003
Distribution: Slackware
Posts: 4,113

Rep: Reputation: Disabled
A delimiter is what defines the fields - in other words, what $2, $6 and $9 are are defined as what the delimiter is *not*. So


means $1 is 'foo' and $2 is 'bar<tab>baz' if the delimiter is just a space and 'foo<space>bar' and 'baz' if the delimiter is just a tab.

As far as the single quote, there should be a final quote as well and it just protects the awk 'program' from being interpreted by the shell. The 'search' part of it is the '/and/' part, which says to apply the '{}' rule to records matching that expression. Might try checking out the info manual for gawk, which is a form of a published book on the subject.

Last edited by slakmagik; 04-08-2007 at 12:51 AM. Reason: clarifying a point
Old 04-08-2007, 01:29 AM   #3
LQ Newbie
Registered: Mar 2007
Posts: 21

Original Poster
Rep: Reputation: 15
Smile thankyou

thanks so much. i'll check it out. i should've thought harder, i might've recalled the bit about protecting from shell interpretation. thanks again.



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

Similar Threads
Thread Thread Starter Forum Replies Last Post
awk - check $1 is a linux command or not? kalyanofb Programming 4 02-07-2007 08:51 AM
awk command to take average? johnpaulodonnell Linux - Newbie 3 02-07-2007 05:11 AM
Awk - get a parameter from the command line benjalien Programming 1 01-24-2006 10:06 AM
Sed/Awk command help needed. farmerjoe Programming 3 03-02-2005 12:13 PM
cut / awk command?? Sammy2ooo Linux - Newbie 1 05-27-2003 06:46 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:35 AM.

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