substituting the character ")" in gawk

Hi,

I am using gawk to substitute the character ")" with ")\n" using sub function but it gives me the following error:

gawk: cmd. line:3: (FILENAME=  FNR=11) fatal: Unmatched \):/),/

The command is:

gawk '
/^[ \t]*function.*\(/,/\)/{sub(")",")\n")}
'

It works for me; I don't get any error message with GNU Awk 3.1.6 (or POSIX awk). What version are you using?

You could try an alternative syntax:

/^[ \t]*function.*\(/,/\)/{sub("[)]",")\n")}

/^[ \t]*function.*\(/,/\)/{sub(/)/,")\n")}

/^[ \t]*function.*\(/,/\)/{sub(/[)]/,")\n")}