I have a ksh script that utilizes nawk to set some variables. It is running succesfully on two of my domains, one running on a SUN E250 and Solaris 7 and one on a SUN Ultra80 running Solaris 8. On my third domain, I have the same script running on an Ultra10 under Solaris 8 and on only this system, nawk errors out with a "newline in string" error.
In the following example, filelist is a newline delimited file containing the full path to each file to process. The file is the result of redirecting the output of ls -1 of all files with a specific extension
to a file named filelist.
The resulting error is as follows:
[highlight]
nawk: syntax error at source line1
context is
>>>/path/to/file/filname. <<< ext
nawk: bailing out at source line 1
nawk: newline in string
xport... at source line 1
[/highlight]
The ext above is the file extension. There is absolutly not a newline between the filename and the extension.
On the two domains where the script is working, I used CTRL-V CTRL-RTN to enter the newline as the field separator. On the Ultra10, something in the keymapping is preventing me from doing this, so I suspect that nawk is not getting what I expect it to get as the field separator. But, if that is the case, I really don't understand why \n is not working on a Solaris box. Can anyone shed any light?
Thanks.
Derek
In the following example, filelist is a newline delimited file containing the full path to each file to process. The file is the result of redirecting the output of ls -1 of all files with a specific extension
to a file named filelist.
Code:
for i in $(cat filelist);do
SUBJ=$(nawk -F \n '
{
if ( sub(/^[ \t]*SUBJ(: *|\/)|^[ \t]*SUBJECT:[ ]*/, "") )
exit
}
END { print } ' $i
done
The resulting error is as follows:
[highlight]
nawk: syntax error at source line1
context is
>>>/path/to/file/filname. <<< ext
nawk: bailing out at source line 1
nawk: newline in string
xport... at source line 1
[/highlight]
The ext above is the file extension. There is absolutly not a newline between the filename and the extension.
On the two domains where the script is working, I used CTRL-V CTRL-RTN to enter the newline as the field separator. On the Ultra10, something in the keymapping is preventing me from doing this, so I suspect that nawk is not getting what I expect it to get as the field separator. But, if that is the case, I really don't understand why \n is not working on a Solaris box. Can anyone shed any light?
Thanks.
Derek