Why we use head command in Linux?

Why we use head command in Linux?

The head command, as the name implies, print the top N number of data of the given input. By default, it prints the first 10 lines of the specified files.

How many lines will the head command print Defaultly?

10 lines
The head command prints the first lines (10 lines by default) of one or more files or piped data to standard output.

How do I get the first 10 lines in Linux?

To look at the first few lines of a file, type head filename, where filename is the name of the file you want to look at, and then press . By default, head shows you the first 10 lines of a file. You can change this by typing head -number filename, where number is the number of lines you want to see.

What is the syntax of the head command in Linux?

The head command in Unix or Linux system is used to print the first N lines from the file to the terminal. The syntax of head command is. head [options] [files] The head command options are: c : Prints the first N bytes of file; With leading -, prints all but the last N bytes of the file.

How to limit the number of bytes in a head command?

To limit the number of bytes shown with headpass the -coption. Instead of limiting by number of lines this will limit by the number of bytes passed to the -coption. In the following example the output is limited to 16 bytes. head -c 16 /usr/share/dict/words A a AA AAA Aache%

How to pass other commands to head command?

Passing Output of Other command to Head Input You may pass the output of other commands to the head command via pipe as shown below, head [OPTIONS]… [FILE]… to print N bytes from each input file. to print N lines from each input file.

How to combine head and tail in Linux?

For example, if you want to print the lines from 10 to 15 of a file, you can combine the head command with the tail command. The head command prints the first 15 lines of the file. Then the tail command takes this output and prints all the lines starting from line number 10.