Linux命令列表:head
head和tail 就像名字一样,很容易理解。用于在开头或结尾显示一定数量的文本块, head用于将文件的开头显示到标准输出,tail用于显示文件的开头或结尾。文件末尾。
1。命令格式
head [参数]... [文件]...
Shell2.命令功能
head用于将文件的开头显示到标准输出。默认命令 head 打印相应文件中的开头 10。
3。命令参数
-q隐藏文件名-v显示文件名-c显示字节数 > 显示行数
4.使用示例
示例 1:显示文件中的前 N 行
命令:
head -n 5 log.log
Shell演示操作和输出:
[yiibai@localhost test]$ cat log.log
this is line 1.
this is line 2.
this is line 3.
this is line 4.
this is line5.
this is line 6.
this is line 7.
this is line 8.
this is line 9.
this is line 10.
this is line 11.
this is line 12.
this is line 13.
this is line 14.
this is line 15.
this is line 16.
this is line 17.
this is line 18.
this is line 19.
this is line 20.
this is line 21.
this is line 22.
-----------------end
[yiibai@localhost test]$ head -n 5 log.log
this is line 1.
this is line 2.
this is line 3.
this is line 4.
[yiibai@localhost test]$
Shell示例 2:显示文件的前 N 字节
命令:
head -c 20 log.log
Shell演示操作及输出:
[yiibai@localhost test]$ head -c 20 log.log
this is line 1.
this[yiibai@localhost test]$
Shell示例 3:使用 n♿n 命令的文件内容 Shell
Demon运行及输出:
[yiibai@localhost test]$ head -c -32 log.log
this is line 1.
this is line 2.
this is line 3.
this is line 4.
this is line5.
this is line 6.
this is line 7.
this is line 8.
this is line 9.
this is line 10.
this is line 11.
this is line 12.
this is line 13.
this is line 14.
this is line 15.
this is line 16.
this is line 17.
this is line 18.
this is line 19.
this is line 20.
this is line 21.
[yiibai@localhost test]$
Shell 示例 4:打印文件除最后 n 行之外的全部内容
命令:
head -n -6 log.log
```shell
演示操作及输出:
```shell
[yiibai@localhost test]$ head -n -6 log.log
this is line 1.
this is line 2.
this is line 3.
this is line 4.
this is line5.
this is line 6.
this is line 7.
this is line 8.
this is line 9.
this is line 10.
this is line 11.
this is line 12.
this is line 13.
this is line 14.
this is line 15.
this is line 16.
this is line 17.
this is line 18.
[yiibai@localhost test]$ 版权声明
本文仅代表作者观点,不代表Code前端网立场。
本文系作者Code前端网发表,如需转载,请注明页面地址。
code前端网