ericj
ericj

Reputation: 2301

In gawk gensub prints only one backslash

Here under, I expected two back slashes, but get one,

$ awk '{$0=gensub(/\[/,"\\\\","g")}1' <(echo [)
\

sub works okay.

Thanks,

Eric J.

Upvotes: 0

Views: 88

Answers (1)

H&#229;kon H&#230;gland
H&#229;kon H&#230;gland

Reputation: 40778

The behavior is explained here: http://www.gnu.org/software/gawk/manual/gawk.html#Gory-Details

From that link it can be seen that the there is a difference in behavior depending upon

  • which version of awk you are using, and
  • if you use gensub() or sub()

Upvotes: 2

Related Questions