echo "123456" >> 0.txt cat 0.txt "123456" cat filename | tail -n +500 | head -n 100 //打印部分行 echo "123456"| tee -a 0.txt printf "123456" >>0.txt //和echo功能相同,並提供更多的格式
touch test.txt echo 123456 >> test.txt cat test.txt touch test2.txt cat test.txt > test2.txt // cat -n test.txt > test2.txt 加行號寫入//cat -b test.txt test2.txt >test3.txt //合併寫入 cat test2.txt
print:
https://www.runoob.com/linux/linux-comm-cat.html
#########################################################################################################
Linux命令: cat 和>, >>
“>’”覆蓋
">>" 追加
使用>> 重定向後 文件 中原本的內容不會被覆蓋,而是在原有的內容後面 追加 新的內容
cat
cat 原單詞concatenate(用途是連接文件或標準輸入並打印。)
cat 命令用於將所有文件內容打印到屏幕上。
語法:
cat 文件名
實戰
使用xshell連接linux
進入 /root 目錄
新建 catTest目錄
進入 catTest 目錄
新建 a.txt 文件
查看/root目錄下的詳細內容 ,將內容重定向到 a.txt 文件中
ls -l /root > a.txt
查看 a.txt
cat a.txt
查看/root目錄下的內容 ,將內容重定向到 a.txt 文件中, 再次查看 a.txt ,原有的內容被覆蓋,只存在新的內容
ls /root > a.txt
cat a.txt
將/root目錄下的詳細內容 追加到 a.txt,再次查看a.txt文件
ls -l /root >> a.txt
cat a.txt
https://www.jianshu.com/p/8365c5fd9de2