head - output the first part of files
读取文件的前n行,默认前10行
语法:
head [OPTION]... [FILE]...
参数:
- -n 数字 显示前n行,指定数字,可以省略n,直接-1表示前1行
- head -n 5 a.txt 显示前5行
省略-n,直接接-5,表示读取前5行
- -n 复数 显示除了最后的n行,不显示最后n行
- head -n -10 a.txt 不显示a.txt的最后10行,其余都显示
- -c, --bytes 接数字。显示前n个字节
- head -c 5 a.txt 显示文件的前5个字节
【Linux常见命令】head命令
原文:https://www.cnblogs.com/zoe233/p/11815782.html