System() call in nawk
Quang Ngo
quang at CSUFRES.CSUFRESNO.EDU
Thu May 16 02:29:34 AEST 1991
I have a question about nawk. Why does the command 'system' know id but
not f[i]? It says
nawk: f[i]: No such file .....
However, if I change it to
if (system("grep id 1fl_87.txt") == 1)
then it works okay.
Thank you,
-Quang (quang at csufres.CSUFresno.EDU)
--------------------------
BEGIN {
f[0] = "1fl_87.txt"
f[1] = "2sp_88.txt"
f[2] = "3fl_88.txt"
f[3] = "4sp_89.txt"
f[4] = "5fl_89.txt"
f[5] = "6-SP90"
}
{
id = substr($0,34,9)
for (i=0; i<6; i++)
if (system("grep id f[i]") == 1)
printf("%s %d\n",id,i)
}
--------------------------
More information about the Comp.unix.questions
mailing list