2016年7月26日星期二

Linux_105:常用命令之三十二:head、tail

1. head [ -n ] file
用来显示一个文件的最开始几行。
例子:
(1)head -n 5 file
(2)ls -1ut /Users/maping | head -5
某目录中访问最频繁的五个文件。

2. tail [ -n ] file
用来显示一个文件的最后几行。
例子:
(1)tail -n 5 file
(2)ls -1rt /Users/maping | tail -5
某目录中最长时间没有访问的五个文件
(3)tail -f /var/log/httpd/access_log

实时跟踪 follow 选项 -f

没有评论: