(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
|
阅读(1476) | 评论(0) | 转发(0) |