Linux head 命令 - 显示文件头部
介绍
head 命令可用于查看文件的开头部分的内容,默认显示前 10 行的内容。
语法:
head [OPTION]... [FILE]...
选项:
-q:隐藏文件名。-v:显示文件名。-c,--bytes=[-]NUM:显示的字节数。-n,--lines=[-]NUM:显示的行数。
示例
显示 getiot.log 文件的开头 10 行:
head getiot.log
显示 getiot.log 文件的开头 5 行:
head -n 5 getiot.log
显示 getiot.log 文件除最后 5 行外的其他所有内容:
head -n -5 getiot.log
显示 getiot.log 文件前 233 个字节:
head -c 233 getiot.log
