LinuxQuestions.org
Review your favorite Linux distribution.
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 05-12-2005, 06:00 AM   #1
paraiso
Member
 
Registered: Apr 2005
Distribution: Fedora Core 4
Posts: 88

Rep: Reputation: 15
Question AWK question


Code:
 
read x
awk '$2== $x {print $1}' list_file
awk doesn't accept the x argument, why ?


Cheers
 
Old 05-12-2005, 07:19 AM   #2
jkobrien
Member
 
Registered: Jun 2003
Location: Dublin, Ireland
Distribution: Slackware, LFS, Ubuntu, RedHat, Slamd64
Posts: 507

Rep: Reputation: 30
Try...

awk '$2 == XVAR {print $1}' XVAR=$x list_file

XVAR can be anything you like.
 
Old 05-12-2005, 08:06 AM   #3
paraiso
Member
 
Registered: Apr 2005
Distribution: Fedora Core 4
Posts: 88

Original Poster
Rep: Reputation: 15
Thanks a lot jkobrien! that was exactly the answer to my problem. Do you know if it's possible with awk to override the case sensitivity for the variable entered by the user($x)?


Thanks
 
Old 05-12-2005, 08:13 AM   #4
jkobrien
Member
 
Registered: Jun 2003
Location: Dublin, Ireland
Distribution: Slackware, LFS, Ubuntu, RedHat, Slamd64
Posts: 507

Rep: Reputation: 30
Check out the awk manpages. There are two string functions, toupper and tolower, that could help you with that.
 
Old 05-12-2005, 08:25 AM   #5
paraiso
Member
 
Registered: Apr 2005
Distribution: Fedora Core 4
Posts: 88

Original Poster
Rep: Reputation: 15
I'm looking for something similar to the -i option from grep.

Thanks again for taking the time to answer
 
Old 05-12-2005, 01:37 PM   #6
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,965
Blog Entries: 11

Rep: Reputation: 865Reputation: 865Reputation: 865Reputation: 865Reputation: 865Reputation: 865Reputation: 865
And you'll find that in the man-page, too. Highly recommended
reading, even though it's admittedly easier (not necessarily faster)
to have the LQ members do the information extraction for you.



Cheers,
Tink
 
  


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 question puishor Programming 2 08-26-2005 09:44 AM
awk question denalitastic Linux - Newbie 1 06-07-2005 10:42 AM
awk question jonlake Linux - Software 2 05-04-2005 03:58 PM
awk question dilberim82 Programming 2 10-01-2003 07:12 PM
awk question (mandrake 8.2) Frauke Linux - Newbie 0 09-19-2002 04:05 PM


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