1、輸入輸出的區別:
>>和>都屬於輸出重定向,<屬於輸入重定向。
[root@yu test]# cat abc F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME CMD 0 R 0 3374 25827 0 80 0 - 38301 - pts/0 00:00:00 ps 4 S 0 25827 25788 0 80 0 - 29224 do_wai pts/0 00:00:00 bash [root@yu test]# wc -l < abc 3
2、文件內容的區別:
>會覆蓋目標的原有內容。當文件存在時會先刪除原文件,再重新創建文件,然后把內容寫入該文件;否則直接創建文件。
>>會在目標原有內容后追加內容。當文件存在時直接在文件末尾進行內容追加,不會刪除原文件;否則直接創建文件。
[root@yu test]# who > psfile [root@yu test]# cat psfile root pts/0 2021-08-25 17:36 (58.249.3.13) [root@yu test]# pwd >> psfile [root@yu test]# cat psfile root pts/0 2021-08-25 17:36 (58.249.3.13) /root/test [root@yu test]# echo "abc" > psfile [root@yu test]# cat psfile abc