I've never run into a situation before now where there was a difference between backticks and $(). I prefer $() because I think it's easier to read. OTOH, backticks are the standard. Only Bash supports $() AFAIK.
The Bash manual doesn't say anything about backticks being treated differently than $(), except for maybe this vague statement:
When using the $(command) form, all characters between the parentheses make up the command; none are treated specially.
I guess that could mean that $() "quotes the command more", in the sense that backticks treat the command sort of like a string with the associated string processing.
If I set hello to "C:\windows\fails\at\paths" and then run your code, I need to double escape the search pattern when using the backticks.
Code:
$ hello="C:\\windows\\fails\\at\\paths"; echo $hello
C:\windows\fails\at\paths
$ var=`echo $hello | awk '{ gsub(/\\/, "/"); print }'`; echo $var
awk: line 1: runaway string constant "); print } ...
bash: echo: write error: Broken pipe
$ var=`echo $hello | awk '{ gsub(/\\\\/, "/"); print }'`; echo $var
C:/windows/fails/at/paths
$ var=$(echo $hello | awk '{ gsub(/\\/, "/"); print }'); echo $var
C:/windows/fails/at/paths
I have no idea if this is the problem you were seeing because you didn't supply enough information.
Bookmarks