LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Using wildcard in awk programming, how ? (https://www.linuxquestions.org/questions/programming-9/using-wildcard-in-awk-programming-how-493461/)

sarajevo 10-18-2006 06:14 AM

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

druuna 10-18-2006 06:27 AM

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.

sarajevo 10-18-2006 07:06 AM

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


All times are GMT -5. The time now is 06:48 PM.