Chinaunix首页 | 论坛 | 博客
  • 博客访问: 69098
  • 博文数量: 24
  • 博客积分: 50
  • 博客等级: 民兵
  • 技术积分: 135
  • 用 户 组: 普通用户
  • 注册时间: 2011-11-24 22:12
文章分类

全部博文(24)

文章存档

2013年(24)

我的朋友

分类: LINUX

2013-04-09 00:23:51

1. Note that $variable is actually a simplified form of ${variable}.
2. An uninitialized variable has no value, however it acts as if it were 0 in an arithmetic operation. This is undocumented (and probably non-portable) behavior, and should not be used in a script.(P31)
3. 此处a的值为21,使用let对变量赋值时,会对等号后面的算术式进行算术运算,将运算后的值赋给变量

点击(此处)折叠或打开

  1. let a=16+5
  2. echo "The value of \"a\" is now $a."
4. 注意代码中的注释。Variable assignment using the $(...) mechanism (a newer method than backquotes).

点击(此处)折叠或打开

  1. a=`ls -l` # Assigns result of 'ls -l' command to 'a'
  2. echo $a   # Unquoted, however, it removes tabs and newlines.
  3. echo
  4. echo "$a" # The quoted variable preserves whitespace.
5. If a script sets environmental variables, they need to be "exported", that is, reported to the environment local to the script. This is the function of the export command. A script can export variables only to child processes.
6. Arguments passed to the script from the command line: $0, $1, $2, ..., ${10}, ${11},...  $0 is the name of the script itself. The special variables $* and $@ denote all the positional parameters. $# Number of args passed (不包括脚本本身).
7. The shift command reassigns the positional parameters, in effect shifting them to the left one notch. The old $1 disappears, but $0 (the script name) does not change.  The shift command works in a similar fashion on parameters passed to a function.

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