Hi Can any one help me with this code. This is created by someone else and i am trying to modify it so i have got very less knowledge about the purpose.
Ok, the code was picking the second last field of a file with the below mentioned awk. Now when i try to pick 7th to last field (by replacing 1 with 7) it gives me the error awk: The field -6 must be in the range 0 to 199.
Please HELP!!!!!
awk -F${SEP} -v tmpfic=${TMPFIC} ' BEGIN { master =0 }
{
if (NR==1 && index("QuoteMast",FILENAME)) master=1;
if (/QUOT_MAIN_ID.*,.*QUOT_MAIN_REVI/ || /Funding,TeamPlay ID,Project Name,MSDD Project/) {
getline;
}
if ($1 ~ /^[a-zA-Z]{3}.?[a-zA-Z]{4}[0-9]?[0-9]{3} *$/)
{
if (NR==2) printf("%s",$0) >> tmpfic; else printf("\n%s",$0) >> tmpfic;
testok = $(NF-1);
}
else {
debut = 0;
printf("%s", $0) >> tmpfic;
testok = $(NF-1);
while(!debut && getline)
{
if ($1 ~ /^[a-zA-Z]{3}.?[a-zA-Z]{4}[0-9]?[0-9]{3} *$/)
{
if ((master && testok=="false") || !master ) {
printf("\n%s",$0) >> tmpfic;
debut=1;
} else { printf("%s", $0) >> tmpfic; }
}
else {
printf("%s", $0) >> tmpfic;
}
testok = $(NF-1);
};
}
}' ${FIC}.$$