Quoted characters do not have a special meaning
以下的命令都一个执行:
touch ‘file1 file2’
ls ‘file1 file2’
rm ‘file1 file2’
touch file1’ ‘file2
ls file1’ ‘file2
rm file1’ ‘file2
touch f’ile1 file’2
ls f’ile1 file’2
rm f’ile1 file’2
touch “file1 file2”
ls “file1 file2”
rm “file1 file2”
touch file1” “file2
ls file1” “file2
rm file1” “file2
touch file”1 f”ile2
ls file”1 f”ile2
rm file”1 f”ile2
Single quotes(‘) is strong quote; double quote(“) is weak quote;
but backslash(/) is the strongest of all.
If you want to quote single quotes, use double quotes around it.
to quote double quotes, use single quotes
In fact, you don’t want to put quotes within quotes,
you want to combine or concatenate several units into one argument.
For example:
awk ‘{print $’$1’}’
the shell breaks up the argument to awk into three pieces:
{print $ Quoted
$1 Evaluated
} Quoted
However - there is a problem with this script. If you have a space as an
argument, the script would cause a syntax error A better version would protect
from this happening:
awk ‘{print $’”$1“’}’
再比如:
sed -n ‘s/‘“$1”‘/&/p’
输出单引号
echo /‘
输出双引号
echo /“
输出反斜线
echo //
输出’”/
echo /‘/“//
输出双引号
echo ‘“‘
echo “/“”
输出$HOME
echo ‘$HOME’
输出当前环境变量HOME的内容
echo “$HOME”
输出pwd
echo ‘pwd
‘
输出当前的工作目录
echo “pwd
“
输出单引号
echo ‘’”‘“‘’
echo “‘“
echo ‘’/‘’’