tail
基本介绍
用于显示文件的结尾的内容。在默认情况下,taild命令显示文件的后10行内容
表达式
tail [options] [filenames]
常用参数
-c:输出最后N个字节
-f:
当文件增长时,输出后续添加的数据,当文件不存在时,会立即结束
-F:和-f用法基本一致,但是在文件不存在时会继续重试
-n:
-q:
-s:
-
v:
基本使用
命令:tail test.txt
命令:
tail -n5 test1.txt 或
tail -n 5 test1.txt 或
tail -5 test1.txt 或
tail -n -5 test1.txt
命令:tail -n +5 test1.txt 或 tail +5 test1.txt
命令:tail -f test1.txt 或tailf test1.txt
命令:tail -2f test1.txt
说明:循环输出最后2行
命令:
tail +5c test1.txt 或
tail -c +5 test1.txt
head
基本介绍
head 命令可以将一段文本的开头一部分输出到标准输出。默认输出前十行。可以同时操作多个文件
表达式
head [-n -k ]... [FILE]...
常用参数
-c:输出多少个字节
-n:输出多少行
-q:
-
v:
基本使用
命令:
head -n3 test1.txt 或
head -n 3 test1.txt 或
head -n +3 test1.txt 或
head -3 test1.txt
命令:head -n -3 test1.txt
命令:head -c5 test1.txt
原文:https://www.cnblogs.com/htyj/p/10278248.html