How does head command work? The head command reads the first few lines of any text given to it as an input and writes them to standard output (which, by default, is the display screen). The square brackets indicate that the enclosed items are optional. By default, head returns the first ten lines of each file name that is provided to it.
What is head and tail command in Linux? As their names imply, the head command will output the first part of the file, while the tail command will print the last part of the file. Both commands write the result to standard output.
How do you head in terminal?
- Enter the head command, followed by the file of which you’d like to view: head /var/log/auth.log.
- To change the number of lines displayed, use the -n option: head -n 50 /var/log/auth.log.
What does head command do in bash? More bash commands
head is used to print the first ten lines (by default) or any other amount specified of a file or files. cat , on the other hand, is used to read a file sequentially and print it to the standard output (that is, it prints out the entire contents of the file).