文本处理之 head, tail

主要介绍一下 linux 下 head, tail 命令的用法

主要作用是 Print the first 10 lines of each FILE to standard output. With more than one FILE, precede each with a header giving the file name.

比如:

$ head file.txt

就是打印出该文件前10行。

如果有很多文件相似的文件想一次查看,并且希望在打印出的数据前也打印出文件名,可以:

$ head -v file*.txt

即可。

如果想打印出文件的前100行,可以:

$ head -n 100 file.txt

非常的简便。

与之类似的就是, tail 命令默认打印文件最后 10行:

$ tail file.txt

或者

$ tail -n 20 file.txt

posted on 2015-10-23 17:24  OA_maque  阅读(125)  评论(0)    收藏  举报

导航