The head command has several options that allow you to customize its behavior. Here are some commonly used options:
-
-n [number]: Specify the number of lines to display. For example, to show the first 5 lines:head -n 5 filename.txt -
-c [number]: Display the first specified number of bytes instead of lines. For example, to show the first 20 bytes:head -c 20 filename.txt -
-q: Suppress the output of the file headers when multiple files are specified. This means it won't print the file name before the output.head -q file1.txt file2.txt -
-v: Print the file name before the output, even when only one file is specified.head -v filename.txt -
--help: Display help information about theheadcommand and its options.head --help -
--version: Show the version information of theheadcommand.head --version
These options can be combined as needed to tailor the output of the head command to your requirements.
