日更第20天:Linux常用命令之head用法

在这里插入图片描述

1. 命令简介

head 命令是用于查看文件开头部分的内容,默认打印文件前10行数据。

官方解释

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.

在线翻译

默认标准情况下,打印输出文件的前10行。如果有更多的文件,每个文件中的数据将以其文件名开头。如果没有指定文件,或者文件为"-",则从标准输入读取。

2. 英文含义

head:头; 头部; 头脑;

3. 语法格式

head [选项]... [文件]...

4. 选项说明

5. 示例说明

显示文件前10行内容

[root@iZ ~]# head -n 10 install.sh
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
LANG=en_US.UTF-8

if [ $(whoami) != "root" ];then
	echo "请使用root权限执行宝塔安装命令!"
	exit 1;
fi

显示文件除了最后10行以外的全部内容

[root@iZ ~]# head -n -10 install.sh
....

–help:显示帮助信息

[root@iZ ~]# head --help
用法:head [选项]... [文件]...
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.

如果没有指定文件,或者文件为"-",则从标准输入读取。

必选参数对长短选项同时适用。
  -c, --bytes=[-]NUM       print the first NUM bytes of each file;
                             with the leading '-', print all but the last
                             NUM bytes of each file
....

–version:显示版本信息

[root@iZ ~]# head --version
head (GNU coreutils) 8.30
Copyright (C) 2018 Free Software Foundation, Inc.
....

好了,今天的学习就到这里!欢迎大家评论区参与交流与讨论,更好的学习与进步!原创不易,欢迎收藏与转发支持!
在这里插入图片描述

系列推荐

Supongo que te gusta

Origin blog.csdn.net/weixin_43980975/article/details/121893142
Recomendado
Clasificación