009-head和tail

1485阅读 0评论2012-12-30 oceanswimmer
分类:LINUX

head用法
command
查看文件的开头N行,支持多文件,多文件时会有标题输出
  1. head -n N file

head的多种实现
  1. $ head -N file #N是用户指定的行数
  2. $ awk 'FNR <= N' file
  3. $ sed Nq file

-------------------------------------------------------------------------------
tail用法
command
查看文件的结尾N行,支持多文件,多文件时会有标题输出
  1. tail -n N file

跟踪日志输出
  1. $ tail -f logfile #此法持续监控某个文件的输出
  2. $ less 后加F #等价形式
  3. # man less : F
  4. Scroll forward, and keep trying to read when the end of file is reached. Normally this command would be used when already at the end of the file. It is a way to monitor the tail of a file which is growing while it is being viewed. (The behavior is similar to the "tail -f" command.)

上一篇:011-sort和uniq和wc
下一篇:[windows] 安装软件报ERROR1406的处理办法