Script in SED and AWK so that it treats consecutive delimiters as one

Hi All,

I am trying to cut to do a cut operation, but since there are seems to be more than one deltimiters in some occasion I am not able to get the exact field. Can you please provide an SED and AWK script for treating the source file in such a way that all consecutive delimiters are treated as one.

Regards,

The awk's input field separator (FS) could be a regular expression, so, for instance, you could specify:

-F',*'

... and multiple , will be considered a single field delimiter:

% print 1,2,,,3 | awk -F',*' '{ print $1,$2,$3, "-->", NF }'
1 2 3 --> 3 

Hi

I tried executing the same but the output is not coming as expected

->print 1,2,,,3 | awk -F',*' '{ print $1,$2,$3, "-->", NF }'
1 2  --> 5

Also can you please provide me SED example of the same.

You're using the old, broken awk (/usr/bin/awk) on Solaris.
Try using nawk or /usr/xpg4/bin/awk.