LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
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
 
Search this Thread
Old 04-07-2007, 11:43 PM   #1
iconicmoronic
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.

IconicMoronic
 
Old 04-07-2007, 11:50 PM   #2
slakmagik
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

foo<space>bar<tab>baz

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-07-2007 at 11:51 PM. Reason: clarifying a point
 
Old 04-08-2007, 12:29 AM   #3
iconicmoronic
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.

iconicmoronic
 
  


Reply


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 07:51 AM
awk command to take average? johnpaulodonnell Linux - Newbie 3 02-07-2007 04:11 AM
Awk - get a parameter from the command line benjalien Programming 1 01-24-2006 09:06 AM
Sed/Awk command help needed. farmerjoe Programming 3 03-02-2005 11:13 AM
cut / awk command?? Sammy2ooo Linux - Newbie 1 05-27-2003 05:46 PM


All times are GMT -5. The time now is 11:05 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