Chinaunix首页 | 论坛 | 博客
  • 博客访问: 27708
  • 博文数量: 11
  • 博客积分: 207
  • 博客等级: 入伍新兵
  • 技术积分: 105
  • 用 户 组: 普通用户
  • 注册时间: 2012-03-16 20:18
文章分类

全部博文(11)

文章存档

2012年(11)

我的朋友

分类: Python/Ruby

2012-04-12 19:42:22

(1)什么是IFS ?
IFS是bash的内部变量,称为内部域分隔符.这个变量用来决定Bash在解释字符串时如何识别域,或者单词边界.

(2)如何查看当前的IFS值?

tekkaman@tekkaman-desktop:~/working/abs_test/IFS$ echo "$IFS"


由于IFS默认为空白(空格,tab和新行),所以使用以上的命令似乎看不到字符。没关系,你可以用od命令看16进制,或是2进制值:

tekkaman@tekkaman-desktop:~/working/abs_test/IFS$ echo "$IFS" | od -t x1
0000000 20 09 0a 0a
0000004

tekkaman@tekkaman-desktop:~/working/abs_test/IFS$ set w x y z;echo "$*"
w x y z

tekkaman@tekkaman-desktop:~/working/abs_test/IFS$ echo "$IFS" | od -t x1
0000000 20 09 0a 0a
0000004
tekkaman@tekkaman-desktop:~/working/abs_test/IFS$ OLDIFS="$IFS"
tekkaman@tekkaman-desktop:~/working/abs_test/IFS$ echo "$OLDIFS" | od -t x1
0000000 20 09 0a 0a
0000004
tekkaman@tekkaman-desktop:~/working/abs_test/IFS$ IFS=":"
tekkaman@tekkaman-desktop:~/working/abs_test/IFS$ echo "$IFS" | od -t x1
0000000 3a 0a
0000002
tekkaman@tekkaman-desktop:~/working/abs_test/IFS$ IFS="$OLDIFS"
tekkaman@tekkaman-desktop:~/working/abs_test/IFS$ echo "$IFS" | od -t x1
0000000 20 09 0a 0a
0000004



阅读(581) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~