@ghostfn1
2016-03-01T09:47:47.000000Z
字数 846
阅读 2124
Shell LinuxUpdate Time:160301 Teusday
大多数 UNIX 系统命令从你的终端接受输入并将所产生的输出发送回到您的终端。一个命令通常从一个叫标准输入的地方读取输入,默认情况下,这恰好是你的终端。同样,一个命令通常将其输出写入到标准输出,默认情况下,这也是你的终端。
1、输出重定向[centos@localhost ~]$ ls > abc[centos@localhost ~]$ cat abcabcgame2.shgame.shhello.sh[centos@localhost ~]$ ls >>abc# Add content but not erase.cat abclst 2 >abc# Output the wrong message2、输入重定向command1 < file1command1 << file13、When run a Unix/Linux command, three files will be open:stdin, stdout and stderr. The file descriptors for them are 0, 1 and 2. As a result, we could use commands like these:command >file 2>&1command >>file 2>&1command &> filecommand &>> file# To save both the wrong and right messages.4、The command won't be shown on the winwod using the dev/null file.$ command > /dev/null$ command > /dev/null 2>&1# stdout and stderrcommand >>abc 2>>def//save to abc and def.Examples:wc < abc# Ctrl+d to exit.wc <<hello>asdca>asa>hello# When you input hello again,it will exit.