Operating System - Linux
1828255 Members
3008 Online
109975 Solutions
New Discussion

wildcards in awk scripting, how use them?

 
SOLVED
Go to solution
debian111
Regular Advisor

wildcards in awk scripting, how use them?

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.

4 REPLIES 4
Alexander Chuzhoy
Honored Contributor

Re: wildcards in awk scripting, how use them?

Use this:

awk ' { if( $9 ~ /^9[123]+[0-9]+/) print $9 }'> /home/some_file.txt
Alexander Chuzhoy
Honored Contributor
Solution

Re: wildcards in awk scripting, how use them?

Sorry, I used 123 instead of 012. Here's a corrected answer:

awk ' { if( $9 ~ /^9[012]+[0-9]+/) print $9 }'> /home/some_file.txt
spex
Honored Contributor

Re: wildcards in awk scripting, how use them?

Hi,

awk '{ if( $9 ~ /^9[012][0-9]{4}$/) print $9 }' < in.txt > out.txt

PCS
debian111
Regular Advisor

Re: wildcards in awk scripting, how use them?

Thanks