Blog
Head command in Linux

head is a command for Unix systems, including GNU/Linux, used to show the first lines or characters from given files, for each separately. By default, it displays the first ten lines, we can change it with the appropriate options.
Cat , less , more are more commonly used to display the contents of files, but view is more useful for working with large numbers of lines.
In the case of the head command, we limit ourselves to the first few files.
head command examples
Command syntax
head option file_name
How to display the first 10 lines of a file with the head command on Linux
head file_name
Show the first N lines of a file in Linux
head -n 6 file_name
The -n option specifies how many rows to display in this case 6 Delete the last N lines of a file on Linux
head -n -5 file_name
Show the first N characters of the file
head -c 10 file_name
Delete the last N characters of the file
head -c -10 file_name
Show filename in header command head
head -n 5 -v file_name
When we are working on several files we will use the command
head -n 5 first_file second_file
Show filename in header command head
head -n 5 -1 first_file second_file