Input string ($INPUT) can be...
3,J Smith,Manager,121,207,197,16,0,61.42
or
3,J Smith,Manager,121,197,16,0,61.42
In the first case NF=9; In the second case NF=8.
I need to remove the 5th field if NF=9 and do nothing if NF=8.
I tried the following...
echo $INPUT | awk -F, '{if (NF==9) $5=""}1'
This does remove the field, but changes the field separator to a space from a ",". I need to keep the "," FS. Please help.
thanks,
AR
3,J Smith,Manager,121,207,197,16,0,61.42
or
3,J Smith,Manager,121,197,16,0,61.42
In the first case NF=9; In the second case NF=8.
I need to remove the 5th field if NF=9 and do nothing if NF=8.
I tried the following...
echo $INPUT | awk -F, '{if (NF==9) $5=""}1'
This does remove the field, but changes the field separator to a space from a ",". I need to keep the "," FS. Please help.
thanks,
AR