- readlink是linux系统中一个常用工具,主要用来找出符号链接所指向的位置。
- 定义变量“=”两边不能有空格,否则会被shell解析错误。
- tee 同时将输出内容显示在屏幕上、记录在文件里
- 三种引号‘’,“”,``。
- rm -rf ‘my document’ ----当命令行里面包含空格时,用单引号包含起来
- 这时也可由用双引号,区别在于双引号的值会被变量的之替换,单引号保持原样。
-
$ ABC=hello $ echo 'string is ${ABC}' string is ${ABC} $ echo "string is ${ABC}" string is hello
反引号实际上就是命令替换
- echo `uname` #等价 echo $(uname)
-
$ echo `uname -a` Linux ubuntu 3.13.0-24-generic #46-Ubuntu SMP Thu Apr 10 19:11:08 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux $ uname -a Linux ubuntu 3.13.0-24-generic #46-Ubuntu SMP Thu Apr 10 19:11:08 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
- 脚本的执行
-
$ vi test.sh $ cat test.sh echo " this is a test" $ ls -al total 12 drwxr-xr-x 2 xwei xwei 4096 Mar 10 16:49 . drwxr-xr-x 16 xwei xwei 4096 Mar 10 15:28 .. -rw-rw-r-- 1 xwei xwei 26 Mar 10 16:49 test.sh $ . test.sh #以source test.sh 方式执行,读入文件中的命令,在当前shell执行,source内置命令,无需执行权限,其可以缩写为一个小数点 this is a test $ ./test.sh # bash: ./test.sh: Permission denied xwei@ubuntu:~/Desktop$ chmod a+x test.sh xwei@ubuntu:~/Desktop$ ls -al total 12 drwxr-xr-x 2 xwei xwei 4096 Mar 10 16:49 . drwxr-xr-x 16 xwei xwei 4096 Mar 10 15:28 .. -rwxrwxr-x 1 xwei xwei 26 Mar 10 16:49 test.sh $ ./test.sh #在一个子shell中执行命令 this is a test
-