LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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, 07: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, 08: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, 09: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, 09: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, 09: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, 02:37 PM   #6
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

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

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:54 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration