Home Common Problem Usage of head command

Usage of head command

Jan 10, 2024 pm 02:07 PM
head command

The head command is used to display the content at the beginning of the file. By default, the head command displays the first 10 lines of the file. Syntax: head [option]... [file]...

Usage of head command

The head command is used to display the content at the beginning of the file. By default, the head command displays the first 10 lines of the file. The specific usage is as follows:

  1. Syntax: head [option]... [file]...
  2. Option:
  • -c , --bytes=[-]K displays the first K bytes of each file; if the "-" parameter is appended, all remaining contents except the last K bytes of each file are displayed
  • - n, --lines=[-]K displays the first K lines of each file; if the "-" parameter is appended, all remaining contents except the last K lines of each file are displayed
  • -q, --quiet, --silent Do not display the file header containing the given file name
  • -v, --verbose Always display the file header containing the given file name
  • --help display This help message and exit
  • --version Display version information and exit
  1. Parameters: File list: Specify the file list to display the header content.

When using the head command, you can choose different options and parameters as needed. For example, to display the first 10 lines of a file, you can use the following command:

head filename.txt
Copy after login

If you want to display the first 5 lines of each file, you can use the following command:

head -n 5 file1.txt file2.txt
Copy after login

If you want To display the first 20 bytes of each file, you can use the following command:

head -c 20 file1.txt file2.txt
Copy after login

In short, the head command is a very practical command line tool for quickly viewing the beginning of the file.

The above is the detailed content of Usage of head command. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)