日更第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.
....

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

系列推荐

  • 2
    点赞
  • 20
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值