天天看點

tail、 more、head、 cat、 echo 檢視檔案内容

# 顯示日志200行

tail -200f cnpl-1_20110719.log 

# 跟蹤日志執行

tail -f  ~/cnpl_bin/Admin_20110520.log

# tailf 其實就是 tail -f 10 

tailf a.txt

# more a.txt 

1. 回車自動下一行

2. 空格自動翻頁

3. 按b自動回到上頁

# cat 可以直接 顯示多個檔案

cat a.txt b.txt

# 内容追加到檔案中

echo "abcfdsfdsfdsdddd" > b.txt 

#  -n 顯示行号

 cat -n a.txt b.txt

     1abcdddd

     2abcfdsfdsfdsdddd

# tail 顯示檔案後幾行,head顯示檔案前幾行 

tail -6 a.txt

head -6 a.txt

# 直接tail 和head 都是顯示對應檔案的後十行和前十行

tail a.txt

head a.txt 

#前10項

ll -t | grep 'root' | head -10

#後10項

ll -t | grep 'root' | tail -10