Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat is the correct usage of (nested | double | simple) quotes
    primarykey
    data
    text
    <p>I'm sure this question may seem foolish to some of you, but I'm here to learn.<br> Are these assumptions true for most of the languages ?<br> <strong>EDIT</strong> : OK, let's assume I'm talking about Perl/Bash scripting. </p> <pre><code>'Single quotes' </code></pre> <p>=> No interpretation at all (e.g. '$' or any metacharacter will be considered as a character and will be printed on screen)</p> <pre><code>"Double quotes" </code></pre> <p>=> Variable interpretation</p> <p>To be more precise about my concerns, I'm writing some shell scripts (in which quotes can sometimes be a big hassle), and wrote this line :</p> <pre><code>CODIR=`pwd | sed -e "s/$MODNAME//"` </code></pre> <p>If I had used single quotes in my sed, my pattern would have been '$MODNAME', right ? (and not the actual value of $MODNAME, which is `alpha' in this particular case)</p> <p>Another problem I had, with an awk inside an echo :</p> <pre><code>USAGE=`echo -ne "\ Usage : ./\`basename $0\` [-hnvV]\n\ \`ls -l ${MODPATH}/reference/ | awk -F " " '$8 ~ /\w+/{print "&gt; ",$8}'\`"` </code></pre> <p>I spent some time debugging that one. I came to the conclusion that backticks were escaped so that the interpreter doesn't "split" the command (and stop right before «basename»). In the awk commmand, '$8' is successfully interpreted by awk, thus not by shell. What if I wanted to use a shell variable ? Would I write awk -F "\"$MY_SHELL_VAR\"" ? Because $MY_SHELL_VAR as is, will be interpreted by awk, won't it ?</p> <p>Don't hesitate to add any information about quoting or backticks !</p> <p>Thank you ! :)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload