冒号在shell中表示空指令。
原文如下:
:
null command [colon]. This is the shell equivalent of a "NOP" (no op, a do-nothing operation). It
may be considered a synonym for the shell builtin true. The ":" command is itself a Bash builtin, and its exit status is true (0).
所以:
: > file 用于清空文件
下面这种形式是Here Document的一种用法,用于注释一段代码块
:<<BLOCK
...
segment
...
BLOCK
http://zhidao.baidu.com/link?url=V1O6LQbnSa8hs8bZx0Dqpyxn9NyDZ4uNIZ2HJH1qLhQw4MSB1ODMGEADy_uI2CZxfz_iR3q1qbqEZeZ_WEVaq_
重定向 > >> < << 两个表示追加
http://www.linuxidc.com/Linux/2012-12/76450.htm
$ who > file
$ cat file1 file2 >> file3
$ mail tom < file
$ find / -name file -print 2> errors
$ (find / -name file -print > /dev/tty) >& errors
说明:
1、命令who的输出从终端被重定向到file。
2、命令cat的输出(连接file1和file2)被附加到file3尾部。
3、file的输入被重定向到mail程序,也就是说,file的内容被送给用户tom。
4、find命令的所有错误都被重定向到文件errors。输出则发往终端。
5、find命令的所有错误都被重定向到文件errors。输出则发往终端。
shell脚本下所有的重定向输入输出均可采用此方式操作。
加载中,请稍候......