In unix shell or commands, we often use Double Quotes (") and Single Quotes ('), but we should understand when we must use Double Quotes or we must use Single Quotes, or we could choose either.
- Single Quotes ('): Shell will send it to Unix Commands without doing any interpretation.
- Double Quotes ("): Shell will send it to Unix Commands after doing interpretation on following characters
- Doller Signs ($)
- Back Quotes (`)
- Backslashs (\)
- Backslashs (\) is the same as Single Quotes (') to the next character followed this Backslash.
For understanding the points above, we must understand the 2 different things: Shell and Unix Commands.
We issue all Unix Commands within Unix Shell environment. Shell will interpret (or say process) strings and variables first before they are sent to Unix Commands. For example: echo, ls are Unix Commands, you will issue these commands in an Unix Shell, like Boune Shell, Kane Shell, etc.
Practice
$ ls
file1 file2
$ echo file*
file1 file2
$ echo "file*"
file*
$ echo $HOME
/home/zhangy
$ echo "$HOME"
/home/zhangy
$ echo '$HOME'
$HOME
Continue to read to see a sample.
Refer to
/home/zhangdaw/> cat testsed
inbasket=/ods/sap/in
filename=$(echo "${inbasket}" | sed 's/\//\\\//g')"\/ash"
echo $filename
echo "ashaaa" | sed -e "s/ash/${filename}/g"
/home/zhangdaw/> ./testsed
\/ods\/sap\/in\/ash
/ods/sap/in/ashaaa
- 文章信息
- 版权声明: 本文可以任意转载,转载时请务必以超链接形式标明文章原始出处和作者信息。
- 原文出处: http://www.aiview.com/
- 写于: 2006-02-28 [Edit]
- 作者: Alex (email &msn)

- 标签 Tags: Shell (8)


