[dywang@dywHome ~]$ cat /etc/crontab /etc/dywang # /etc/crontab 存在,螢幕出現以下 standard output SHELL=/bin/bash MAILTO=root HOME=/ # run-parts 01 * * * * root nice -n 19 run-parts --report /etc/cron.hourly 02 4 * * * root nice -n 19 run-parts --report /etc/cron.daily 22 4 * * 0 root nice -n 19 run-parts --report /etc/cron.weekly 42 4 1 * * root nice -n 19 run-parts --report /etc/cron.monthly # /etc/dywang 不存在,螢幕出現以下 standard error cat: /etc/dywang: No such file or directory
< 或 <<
;
> 或 >>
;
2> 或 2>>
;
>, 1> |
標準輸出至檔案,該檔案被覆蓋或建立。 | ||
>>, 1>> |
標準輸出至檔案,該檔案被建立或累加。 | ||
command | 2> |
裝置或檔案 | 錯誤輸出至檔案,該檔案被覆蓋或建立。 |
2>> |
錯誤輸出至檔案,該檔案被建立或累加。 | ||
< |
輸入 | ||
<< |
結束的輸入字元 |
[root@linux ~]# ls -l / > ~/rootfile # 將 ls -l / 要列出到螢幕上的資料『重新導向』到 ~/rootfile 檔案。
~/rootfile
)若不存在,系統會自動建立;
>
輸出到一個既存檔案中,該檔案會被覆蓋。
>
與 >>
# 將目前目錄下的檔案資訊儲存到 list.txt [root@linux ~]# ls -al > list.txt # 將根目錄下的資料累加到 list.txt [root@linux ~]# ls -al / >> list.txt
2>
[csie@linux ~]$ find /home -name testing find: /home/test1: Permission denied %*<== Starndard error*) find: /home/root: Permission denied %*<== Starndard error*) find: /home/masda: Permission denied %*<== Starndard error*) /home/csie/testing %*<== Starndard output*) [csie@linux ~]$ find /home -name testing > list_right 2> list_error [csie@linux ~]$ find /home -name testing > list_right 2> /dev/null
2>&1
:標準輸出與標準錯誤輸出同時寫入同一個檔案
[csie@linux ~]$ find /home -name testing > list 2> list %*<==錯誤寫法*) ## 習題:請問上面命令的執行結果為何? [csie@linux ~]$ find /home -name testing > list 2>&1 %*<==正確寫法*)
[root@kvm7 ~]# grep configure /usr/share/doc/autofs-5.0.7/README ./configure to configure the system. See README.options for options that you can give configure.
[root@kvm7 ~]# grep configure /usr/share/doc/autofs-5.0.7/README > /root/autofs.txt
[root@kvm7 ~]# cat /root/autofs.txt ./configure to configure the system. See README.options for options that you can give configure.