輸出
1、標準輸出
定義:程序在默認情況下輸出結果的地方(stdout)。
2、輸出重定向
定義:用于把數據的輸出轉移到另一個地方去。
3、Ubuntu中例子
$ls > ~/ls_out? ##不顯示在顯示器上而是輸入到文件ls_out中
uname -r > ls_out? ## output the kernal information to the file of ls_out
date > ls_out ##output date to file ls_out
uname >> ls_out? ##add to the tail of ls_out
輸入
1、標準輸入
定義:默認情況下接受輸入的地方。通常指的是鍵盤。
2、輸入重定向 定義:非標準輸入。例如從文件中導入(輸入)等。
3、例子Ubuntu
$cat < days ##print the content in the days to the screen
cat < EOF ##立即文檔,輸入到EOF時停止。
cat << END > hello ##合并使用
管道 |
定義:將“重定向”又向前推了一步。通過一個“|”,將一個命令的輸出連接到另一個命令的輸入。
例子: ls | grep ruby
解析:ls首先列出所有文件的文件名,管道“|”接收到這些輸出并把他們發送給grep命令作為其輸入。最后grep在其中查找包含字符串ruby的文件名,并在標準輸出(顯示器)上面顯示。
?