문제

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

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

sub works okay.

Thanks,

Eric J.

도움이 되었습니까?

해결책

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()
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top