head
The "head" command line tool is used in Unix-like operating systems to display the beginning (or head) of a file. It is primarily designed to output the first few lines of a file to the terminal. The default behavior of "head" is to display the first ten lines of a file, but the number of lines can be specified using the "-n" or "--lines" option followed by a number. For example, "head -n 5 filename.txt" will display the first five lines of the file. It is also possible to specify multiple files as arguments, and "head" will display the specified number of lines for each file. Additionally, the "-c" or "--bytes" option can be used to display a specific number of bytes instead of lines. To display the entire contents of a file except the last few lines, the "-n" option can be preceded by a hyphen ("-"), for example, "head -n -5 filename.txt" will show all lines except the last five. The "head" command can be useful in several scenarios, such as quickly previewing the contents of a large file or extracting relevant information from the beginning of a dataset or log file. There are various options available with "head" to customize its behavior, such as "-q" for quiet mode, which suppresses the file name headers, and "-v" for verbose mode, which displays the file name headers even for single-file inputs. "head" is part of the GNU core utilities and is widely available on Unix-like systems, including Linux. The tool is versatile and frequently used in conjunction with other command line utilities and scripts for effective file manipulation and data processing tasks.
List of commands for head:
-
head:tldr:27370 head: Output the first few lines of a file.$ head -n ${count} ${filename}try on your machineexplain this command
-
head:tldr:357b3 head: Output the first few bytes of a file.$ head --bytes ${count} ${filename}try on your machineexplain this command
-
head:tldr:b6b93 head: Output everything but the last few bytes of a file.$ head --bytes -${count} ${filename}try on your machineexplain this command
-
head:tldr:db727 head: Output the first few lines of a file.$ head --lines ${count} ${filename}try on your machineexplain this command
-
head:tldr:fa104 head: Output everything but the last few lines of a file.$ head --lines -${count} ${filename}try on your machineexplain this command