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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
05-12-2005, 07:00 AM
|
#1
|
Member
Registered: Apr 2005
Distribution: Fedora Core 4
Posts: 88
Rep:
|
AWK question
Code:
read x
awk '$2== $x {print $1}' list_file
awk doesn't accept the x argument, why ?
Cheers
|
|
|
05-12-2005, 08:19 AM
|
#2
|
Member
Registered: Jun 2003
Location: Dublin, Ireland
Distribution: Slackware, LFS, Ubuntu, RedHat, Slamd64
Posts: 507
Rep:
|
Try...
awk '$2 == XVAR {print $1}' XVAR=$x list_file
XVAR can be anything you like.
|
|
|
05-12-2005, 09:06 AM
|
#3
|
Member
Registered: Apr 2005
Distribution: Fedora Core 4
Posts: 88
Original Poster
Rep:
|
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
|
|
|
05-12-2005, 09:13 AM
|
#4
|
Member
Registered: Jun 2003
Location: Dublin, Ireland
Distribution: Slackware, LFS, Ubuntu, RedHat, Slamd64
Posts: 507
Rep:
|
Check out the awk manpages. There are two string functions, toupper and tolower, that could help you with that.
|
|
|
05-12-2005, 09:25 AM
|
#5
|
Member
Registered: Apr 2005
Distribution: Fedora Core 4
Posts: 88
Original Poster
Rep:
|
I'm looking for something similar to the -i option from grep.
Thanks again for taking the time to answer
|
|
|
05-12-2005, 02:37 PM
|
#6
|
Moderator
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
|
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
|
|
|
All times are GMT -5. The time now is 04:54 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|