Skip to content

Instantly share code, notes, and snippets.

@kujyp
Created July 15, 2019 05:59
Show Gist options
  • Save kujyp/ba3d7be1bb5e7e44e03c5b350fb10bcf to your computer and use it in GitHub Desktop.
Save kujyp/ba3d7be1bb5e7e44e03c5b350fb10bcf to your computer and use it in GitHub Desktop.
subshell ``, $() check differences
#!/bin/bash
a=abc!!
echo a=[$a]
echo ""
result=`echo $a | sed -e 's/!/\\\\!/g'`
echo \`~\`=[$result]
echo ""
result=$(echo $a | sed -e 's/!/\\\\!/g')
echo \$\(~\)=[$result]
echo ""
# > a=[abc!!]
# >
# > `~`=[abc\!\!]
# >
# > $(~)=[abc\\!\\!]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment