Check if the text file has more than 2 characters

Guys,

I know that the below command will cut the 13th field from test.txt file

awk -F"|" '{print $13}' test.txt

The answer would be,

CA
CN 
Ohio

If we see the 3 rd one, it has more than 2 characters. So i wanted to check this in if condition and i want to get the output if the 13th field has more than 2 characters.:confused:

Any help would be greately appreciated!!!

awk -F'|'  'length($13)>2' inputfile > outputfile

Thank you! Great...
It worked fine.. But this displaying the whole content..
Is there any way to display particular 13th field?

Try...

awk -F'|'  'length($13)>2 {print $13}' inputfile > outputfile 

Cool. Thank you :slight_smile: