Hi,
I'm trying to get the substr on a string and getting the below error.
|0060776818860803181712HMEHME0192HM01 A+0400UNKHMESMDEPART 1903 AM/PM 0000 |
awk: Field $(|0060776824460803181712HMEHME0192HM01 A+0400UNKHMESMUSNEXTDAY
0000 |)
is not correct.
The input line number is 1309. The file is kk.
The source line number is 3.
The code is:
awk '/\|00/ && /SM/ && /USNEXTDAY/ && (length($0) == 145) {CL=$0;
print CL;
status_code = substr($CL,51,2);
if (status_code != NULL && status_code == "SM")
{
remarks=substr($CL,53,44);
if (remarks != NULL && remarks ~ "USNEXTDAY")
{
awb=substr($CL,4,10);
dest=substr($CL,48,3);
printf ("Status code %2c\n",status_code);
printf ("Remarks %44c\n",remarks);
printf ("Airwaybill Number %10d\n",awb);
printf ("Destination %3c\n",dest);
}
}
next;
}' kk
Also, how will the awk react if the returned substring is NULL? Any idea?
Rgds,
I'm trying to get the substr on a string and getting the below error.
|0060776818860803181712HMEHME0192HM01 A+0400UNKHMESMDEPART 1903 AM/PM 0000 |
awk: Field $(|0060776824460803181712HMEHME0192HM01 A+0400UNKHMESMUSNEXTDAY
0000 |)
is not correct.
The input line number is 1309. The file is kk.
The source line number is 3.
The code is:
awk '/\|00/ && /SM/ && /USNEXTDAY/ && (length($0) == 145) {CL=$0;
print CL;
status_code = substr($CL,51,2);
if (status_code != NULL && status_code == "SM")
{
remarks=substr($CL,53,44);
if (remarks != NULL && remarks ~ "USNEXTDAY")
{
awb=substr($CL,4,10);
dest=substr($CL,48,3);
printf ("Status code %2c\n",status_code);
printf ("Remarks %44c\n",remarks);
printf ("Airwaybill Number %10d\n",awb);
printf ("Destination %3c\n",dest);
}
}
next;
}' kk
Also, how will the awk react if the returned substring is NULL? Any idea?
Rgds,