用镜头记录,用心灵体验 | 订阅本站 | 所有笔记 | 亲和力设计 | 流量

DB2 学习笔记

博客话题:DB2,Linux,Web,业余无线电,户外,摄影,截拳道,Thankpad,其他

Unix Shell

difference in Double quotes and Single quotes

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

Alex's picture

my email address in picture

搜索|Search

评论|Recent Comments

按月归档|By Month

2009
07
2008
11
10
07
05
04
03
02
01
2007
12
10
07
06
05
04
03
02
01
2006
12
11
10
09
08
07
06
05
04
03
02
01
2005
11
10
09
08
07
04
03
2004
12
11
10
09
08
07
06
05
04
03
02
01
2003
12
10
09
08
06
2002
09
08
04
03
02
2001
12
09
07
06
05

我读|My Books

我的链接|My Links

我的朋友|My Friends

Creative Commons License
This blog is licensed under a Creative Commons License.
Movable Type 4 Logo