一、cat命令
對文件內容正序查看時,可以使用cat命令。還可以兩多個文件輸出到一個文件中。也可以新建一個文件。下面就介紹一下cat命令的用法。
cat filename 正序查看文件所有內容
cat -n filename 帶行號正序查看文件所有內容
cat -b filename 忽略空白行,帶行號正序顯示文件所有內容
cat > filename 新建一個文件
cat filename1 filename2 > filename3 將filename1 filename2合併爲filename3,此時filename3中只有filename1和filename2文件中的內容
cat filename1 filename2 >> filename3 將filename1 filename2文件的內容追加到filename3文件中
cat /dev/null > filename 清空filename文件中的內容
二、tac命令
tac倒過來就是cat,是將文件倒着顯示,即文章最後一行顯示在最上邊。使用方法如下
tac filename
三、tail命令
tail命令是指定顯示文件後若干行的內容。下面介紹一下具體使用方法。
1.tail -f filename 顯示filename文件尾部內容,默認是10行,相當於tail -n 10,但是會不斷刷新顯示到屏幕上
2.tail -n number filename 顯示filename文件尾部number行內容
3.tail -n +number filename 從第number行顯示文件內容
四、head命令
head 顯示前n行的內容
head -n number filename