Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1724974
  • 博文数量: 362
  • 博客积分: 10587
  • 博客等级: 上将
  • 技术积分: 4098
  • 用 户 组: 普通用户
  • 注册时间: 2009-09-10 18:15
文章分类

全部博文(362)

文章存档

2014年(1)

2013年(58)

2011年(115)

2010年(112)

2009年(76)

分类:

2010-10-05 16:41:09

#!/bin/bash
# weirdvars.sh: Echoing weird variables.

echo

var="'(]\\{}\$\""
echo $var        # '(]\{}$"
echo "$var"      # '(]\{}$"     Doesn't make a difference.

echo

IFS='\'
echo $var        # '(] {}$"     \ converted to space. Why?
echo "$var"      # '(]\{}$"

IFS='$'
echo $var        # '(]\{} "     \ converted to $. Why?
echo "$var"      # '(]\{}$"
# Examples above supplied by Stephane Chazelas. echo var2="\\\\\"" echo $var2 # " echo "$var2" # \\" echo # But ... var2="\\\\"" is illegal. Why? var3='\\\\' echo "$var3" # \\\\ # Strong quoting works, though. exit

NO.2
echo "Why can't I write 's between single quotes"

echo

# The roundabout method.
echo 'Why can'\''t I write '"'"'s between single quotes'
#    |-------|  |----------|   |-----------------------|
# Three single-quoted strings, with escaped and quoted single quotes between.

# This example courtesy of St閜hane Chazelas.

N0.3
bash$ echo hello\!
hello!


bash$ echo "hello\!"
hello\!


bash$ echo -e x\ty
xty


bash$ echo -e "x\ty"
x       y
	      
阅读(697) | 评论(0) | 转发(0) |
0

上一篇:引用变量

下一篇:退出/退出状态码

给主人留下些什么吧!~~