Finding multiple column values and match in a fixed length file

Hi,

I have a fixed length file where I need to verify the values of 3 different fields, where each field will have a different value.

How can I do that in a single step.

Hi,
Post your input and expected output.

File A.txt is something like

abc20100719|ab|P|C|zz|UE|USD|85|zz|zzz

I Need to find out the 16th character and match with P and i need 23-24 characters mathches with UE and 30-31 characters matches with 85.

Please note that the value 85 is not the end of the record. Still there are other fields in the record.

echo 'abc20100719|ab|P|C|zz|UE|USD|85|zz|zzz' | cut -c16
echo 'abc20100719|ab|P|C|zz|UE|USD|85|zz|zzz' | cut -c23-24
echo 'abc20100719|ab|P|C|zz|UE|USD|85|zz|zzz' | cut -c30-31

Cleaned.:slight_smile:

awk -F '|' 'NFS=OFS="|" {if ($3=="P" && $6=="UE" && $8=="85") {print $0}}' data.file

# cat san|awk -F"|" '{if(($3~P)&&($6~E)&&($8~85))print $0}'
abc20100719|ab|P|C|zz|UE|USD|85|zz|zzz
#