Quote:
Originally Posted by
vgersh99
It's been awhile since I dealt with Solaris' nawk, but it did have its quirks..
I'd start with: "$awkcmd" -F"#|#"
What do you think your field separator is?
A string #|# ? Maybe or maybe not. It might be a regex: # OR #.
I'd debug this first with the debug printf for each field.
Or try "#[|]#" to force it into a string.
Also: if ( $p=="|" || $p=="#|" || $p=="#" || $p=="|#" ) doesn't make too much sense given your definition of of the field separator.
Post sample input and the desired output.
Setting
FS to
#|# (via direct assignment or by using the
-F option) should effectively set the field separator to an octothorpe (i.e.
#) on any
awk based on the version of
awk that Aho, Weinberger, and Kernighan released in 1988. The
/usr/bin/awk or
/bin/awk provided on SunOS and System V was an earlier version of
awk.
So when the real field separator is
#|# instead of the
# matched by
FS, the code will frequently find a field containing just
|. But, it will never find a field containing
#|,
#, or
|# since
# is the field separator.
As you said, using
-F"#[|]#" instead of
-F"#|#", should get rid of that problem. But, since there is no
| in the
hashTables[] array, I don't see why that check would ever be needed as long as the field separators in the 1st line of an input file are the same as the field separators on the other lines in that file.