LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-18-2006, 06:14 AM   #1
sarajevo
Member
 
Registered: Apr 2005
Distribution: Debian, OpenBSD,Fedora,RedHat
Posts: 228
Blog Entries: 1

Rep: Reputation: 31
Using wildcard in awk programming, how ?


Hi people,
I have statement
awk ' { if(( $9=90*) && ($9=91*) && ($9=92*)) print $9 }'> /home/some_file.txt
where with * I want to select all numbers which begin with 90, 91, 92, and no mater which number is later. There is 4 numbers after 90, 91, 92.

how use wild wildcards in this case to print out all that numbers.

Thanks
 
Old 10-18-2006, 06:27 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi,

Is this what you want:

awk '$9 ~ /^9[0-2]/ { print $9 }' infile > outfile

This checks to see if field 9 starts (^) with a 9, followed by 0,1 or 2 ([0-2]). If this is the case field 9 is printed, no matter what else is after ^9[0-2].

Hope this helps.
 
Old 10-18-2006, 07:06 AM   #3
sarajevo
Member
 
Registered: Apr 2005
Distribution: Debian, OpenBSD,Fedora,RedHat
Posts: 228

Original Poster
Blog Entries: 1

Rep: Reputation: 31
Quote:
Originally Posted by druuna
Hi,

Is this what you want:

awk '$9 ~ /^9[0-2]/ { print $9 }' infile > outfile

This checks to see if field 9 starts (^) with a 9, followed by 0,1 or 2 ([0-2]). If this is the case field 9 is printed, no matter what else is after ^9[0-2].

Hope this helps.
Thank you very much.

Regards
 
  


Reply



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
wildcard vs regular expression lido Linux - Newbie 6 09-02-2004 10:35 AM
I choose you wildcard! tearinox Linux - Newbie 2 01-23-2004 08:44 PM
how to find file using wildcard? huangyanfeng Linux - General 3 10-15-2003 09:21 PM
Recursive wildcard copying? meeshka Linux - Newbie 7 07-11-2003 01:44 AM
Help with wildcard searching in Perl AnthonyM Programming 2 06-17-2003 02:43 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:31 AM.

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