Help with awk command

Hi ,

I am writing a awk script which will check the values in field 1 and field 2 based on these values the awk has to update field 4.

Source data

ABC,XYZ,1,2,3,XXXXXXXXXXXXXX,1,2,3
ABC,123,1,2,3,XXXXXXXXXXXXXXX,1,2,3
ABC,DEF,1,2,3,XXXXXXXXXXXXXXX,1,2,3
ABC,123,1,2,3,XXXXXXXXXXXXXXX,1,2,3

target data

ABC,XYZ,1,2,3,This is a valid record,1,2,3
ABC,123,1,2,3,XXXXXXXXXXXXXXX,1,2,3
ABC,DEF,1,2,3,This is a valid record,1,2,3
ABC,123,1,2,3,XXXXXXXXXXXXXXX,1,2,3

pls tell me how can i compare two times in awk example.

I tried writing the below awk ..but it's wrong and not giving me the required output

awk '{$1=='ABC" ;$2=="XYZ" } print $6=='This is a valid record'
END 

where I am doing wrong in the above script.

Regards,
Deepti

awk -F, '$1=="ABC"&&($2=="XYZ"||$2=="DEF") {$6="This is a valid record"}1' infile

Thanks kevintse.

---------- Post updated at 11:26 PM ---------- Previous update was at 07:34 PM ----------

hey The code is removing the delimters and getting the entire line value in the first column as below.

ABCDEF123This is a valid record123

Regards,
Deepti

Sorry, I didn't test the code, now it should work:

awk -F, '$1=="ABC"&&($2=="XYZ"||$2=="DEF") {$6="This is a valid record"}1' OFS="," infile

Thanks Kevintse, it working can you please tell me why we are using 1' after the record word, i executed it with out the 1 the script is returning nothing .., what exactly 1 will do here and do we have more options which can be used in the place of 1...

I just want to know the various options I have started studing the awk but if you can explain that will be helpful

awk -F, '$1=="ABC"&&($2=="XYZ"||$2=="DEF") {$6="This is a valid record"}1' OFS="," infile

The preceding script can be rewritten a little verbosely as the following:

awk -F, '$1=="ABC"&&($2=="XYZ"||$2=="DEF") {$6="This is a valid record"}1{print}' OFS="," infile

or

awk -F, '$1=="ABC"&&($2=="XYZ"||$2=="DEF") {$6="This is a valid record"}{print}' OFS="," infile

Actually it can be any number that is not 0, which evaluates to FALSE.
A typical awk program will contain PATTERN{ACTION}, either PATTERN or ACTION is optional, but not both. When PATTERN is absent, ACTION will always be executed, when ACTION is absent, it defaults to {print}.

So now you should be able to figure out what that one liner does.