You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# another example
$ echo'\learn\by\example'| awk '{gsub("\\\\", "/")} 1'
/learn/by/example
$ echo'\learn\by\example'| awk '{gsub(/\\/, "/")} 1'
/learn/by/example
In these examples, we don't escape the incoming text '\learn\\by\\example' with extra slashes and so echo returns the wrong string \learyample on pipe for awk.
The text was updated successfully, but these errors were encountered:
Edit: That said, I just checked it from my TUI apps and I see the behavior as you mention. I'll look into it further or may be just use printf and avoid all the trouble.
Ah, I meant printf '\\learn\\by\\example\n' so that it'll behave the same everywhere, unlike echo that differs in how it handles backslashes based on the implementation.
Hi, in the regular expressions chapter, I found an inaccuracy related to escaping characters in the incoming input.
Matching the metacharacters
Using string literal as a regexp
In these examples, we don't escape the incoming text
'\learn\\by\\example'
with extra slashes and so echo returns the wrong string\learyample
on pipe for awk.The text was updated successfully, but these errors were encountered: