Searching for a pattern

How do I search for a pattern - N/A in a particular column using awk?

$n ~ pattern

The problem is with the / in between N and A ie N/A.

Could you be more specific?

The content of the column is N/A and I want to filter out/in all records that have the value N/A in that column.

To match the column set to N/A use this:

$n == "N/A"

To match the column containing the pattern N/A (but eventually not only N/A) use:

$1 ~ "N/A"
1 Like

What is this?

in all seriousness...as I'm sure radoulov's response was as well:

-> print "line1 000\nline2 001\nline3 N/A\nline4 003\nline4 N/A\n" |awk '/N\/A/ {print $0;} '
line3 N/A
line4 N/A

-> print "line1 000\nline2 001\nline3 N/A\nline4 003\nline4 N/A\n" |awk '! /N\/A/ {print $0;} '
line1 000
line2 001
line4 003

Correct,
the dynamic regular expression that I used would be slower.

P.S. I'm quite sure the OP was commenting bankimmehta's post that I deleted.

In fact, using something even closer to radoulov's example:

-> print "line1 000\nline2 001\nline3 N/A\nN/A   003\nline4 N/A\n"                                             
line1 000
line2 001
line3 N/A
N/A   003
line4 N/A

-> print "line1 000\nline2 001\nline3 N/A\nN/A   003\nline4 N/A\n" |nawk '{ if ( $2 == "N\/A" ) {print $0;} } '
line3 N/A
line4 N/A

-> print "line1 000\nline2 001\nline3 N/A\nN/A   003\nline4 N/A\n" |nawk '{ if ( $1 == "N\/A" ) {print $0;} } '
N/A   003

-> print "line1 000\nline2 001\nline3 N/A\nN/A   003\nline4 N/A\n" |nawk '{ if ( $2 == "N/A" ) {print $0;} } ' 
line3 N/A
line4 N/A

what would be the regular expression that can search for a pattern. Pattern is having 8 characters out of which atleast one digit, one lower case, one upper case letter and one special character will be there. But these can occur at any place randomly. Please help me out.
I'm using find $dir -name "test_file.txt" -exec egrep -ni "[a-z]+[A-Z]+[0-9]+['\~', '\!', '\$', '\%', '\^', '\&', '\-', '\=',' \.', '\:', '\;']" {} \; -print

But this will work only for pattern that begins with lower then upper then digit and then special characters. What if they can happen at any random place... :frowning:
Thanks in advance...

follow this..

$ awk -F, '{ if($n=="N/A") print $0 }' <filename>  

specify the delimiter, comma in this case i have considered ...Instead of $n specify the column you want to search for