The head command in Linux: display the first lines of a file

Introduction

In the Linux environment, one of the most useful commands for inspecting text files is head. Its main function is to display the first lines of a file, allowing a quick view without needing to load the entire content into memory. This tool is especially valuable when working with extensive logs, configuration files, or any document where you need to verify the format or initial headers.

Basic Syntax

The simplest way to use head is to simply write its name followed by the file name:

head nombre_del_archivo

This way, head will by default display the first ten lines of the specified file. If no file is provided, head reads from standard input, allowing it to be combined with pipes and other commands.

Most Used Options

    This post is also available in ESPAÑOL.

Leave a Reply

Your email address will not be published. Required fields are marked *

Esta obra está bajo una Licencia Creative Commons Atribución 4.0 Internacional para Francesc Roig francesc@vivaldi.net .