ログコマンドレコードの表示

1020 ワード

背景
最近いろいろなロゴファイルを見ているので、よく使われるコマンドがファイルを見て、記録します.
プロセス
1、先に見るファイルの行数
wc -l xxx.log

2、ファイルの最後の100行を参照
tail -n 20 xx.log
#           10 

3、ファイルのすべての内容を表示する
cat -n xx.log

4、ファイルヘッダ20行の表示
head -n 20 xx.log
#            10 

5、ファイルの変更をリアルタイムで見る
tail -f xx.log

6、ファイルの一部の行を表示する
sed -n '10,100p' xx.log
# p    。   10-100 

7、ファイルを後ろから前へ表示する
tac xxx.log

しかしtacはtailと一緒に使うことができ、debugのロゴを見ることができます(実際にはあまり役に立ちません)
tail xx.log | tac 

8、コンビネーションコマンドファイルの一部の行を表示する
#  3000   ,  100 ,
cat -n xx.log | tail -n 3000 | head -n 100

#   1000 1500 
cat -n xx.log | head -n 1500 | tail -n +1000

#   
tail -n 100 #     100 
tail -n +100 #    100       
head -n 100 #         100 

参考資料
Linuxはファイルの中間の数行を表示します
安利の全文検索ツール:The_silver_searcher----AG