Hi,
I am having a problem with nawk when using -F with more than one separators.
OS: Sun OS 5.8
sh: bourne shell
line to be parsed in file:
test = 2
when I use `nawk -F'[ =]' '{ print $0, NF }' file`
it showed: test = 2 4
and if I tried `nawk -F'[ =]' '{ print $1, $2, $3, $4 }' file`
it showed: test 2
I am quite dummy about nawk, but from my understanding, when we define like -F'[ =]', both space and "=" will be the delimiters, so the NF should be 2 instead of 4, and the second element $2 should be 2 in this example. But the actual result showed that 2 is the forth element $4!
Can anybody here teach me the right way on how to use nawk with more than one separators?
Thanks in advance!
Jiang
I am having a problem with nawk when using -F with more than one separators.
OS: Sun OS 5.8
sh: bourne shell
line to be parsed in file:
test = 2
when I use `nawk -F'[ =]' '{ print $0, NF }' file`
it showed: test = 2 4
and if I tried `nawk -F'[ =]' '{ print $1, $2, $3, $4 }' file`
it showed: test 2
I am quite dummy about nawk, but from my understanding, when we define like -F'[ =]', both space and "=" will be the delimiters, so the NF should be 2 instead of 4, and the second element $2 should be 2 in this example. But the actual result showed that 2 is the forth element $4!
Can anybody here teach me the right way on how to use nawk with more than one separators?
Thanks in advance!
Jiang