head 命令详解

| 选择喜欢的代码风格  

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

head 命令安装:


-bash: head: command not found

#Debian
apt-get install libwww-perl

#Ubuntu
apt-get install libwww-perl

#Alpine
apk add perl-libwww

#Arch Linux
pacman -S perl-libwww

#Kali Linux
apt-get install libwww-perl

#CentOS
yum install perl-libwww-perl

#Fedora
dnf install perl-libwww-perl

#Raspbian
apt-get install libwww-perl

#Docker
docker run cmd.cat/HEAD HEAD

head 命令补充说明:


head 命令用于显示文件的开头的内容。在默认情况下,head 命令显示文件的头 10 行内容

head 命令语法:


head [OPTION]... [FILE]...

head 命令选项:


-n<数字>:指定显示头部内容的行数;
-c<字符数>:指定显示头部内容的字符数;
-v:总是显示文件名的头信息;
-q:不显示文件名的头信息。

以上选项,<数字> 换算关系如下:

...T, P, E, Z, Y 以此类推。
# 数值
b 512
kB 1000
K 1024
MB 1000*1000
M 1024*1024
GB 1000*1000*1000
G 1024*1024*1024

head 命令参数:


文件列表:指定显示头部内容的文件列表。

head 命令实例


显示文件 file 前 10 行内容。

head file.txt

显示文件 file 前 15 行内容。

head -15 file.txt

显示文件 file1 和 file2 的前 10 行内容,并每个文件前会有个 Header 提示。

head file1.txt file2.txt

==> file1.txt <==
CommandNotFound - head Command
CommandNotFound - head Command
CommandNotFound - head Command
CommandNotFound - head Command
...

==> file2.txt <==
CommandNotFound - head Command
CommandNotFound - head Command
CommandNotFound - head Command
...

head 命令扩展阅读:




head 命令评论