help with awk substitution

Hi again.

A have a CSV-file in the following format:

2008.09.01,15:17:42,9227096485,9233175320,CTC10,SMS,0901151742098314,Target_MSIS
DN_is_blacklisted

I want to have an awk command that will say:

If the first 3 digits of $4 does not begin with 922 or 923, then make $8 say "Invalid subscriber."

Is this possible in one awk line?

Hope to hear from you.

Thanks in advance.

:o

awk -F, '{if(substr($4,1,3)=="923" || substr($4,1,3)=="922") print $0; else print $1","$2","$3","$4","$5","$6","$7",Invalid subscriber."}' file

try:

awk -F"," '{ if ($4 !~ /^92[23]/) $8="Invalid subscriber"; print; }' filename

This one worked well!

Thanks!!!! :slight_smile: