Are there any options or flags that can be used with the head command?

Yes, the head command has several options and flags that you can use. Here are some commonly used ones:

  • -n NUM: Outputs the first NUM lines of the file. For example, head -n 5 filename.txt will display the first 5 lines.
  • -c NUM: Outputs the first NUM bytes of the file. For example, head -c 10 filename.txt will display the first 10 bytes.
  • -q: Suppresses the output of the file name when multiple files are specified.
  • -v: Always outputs the file name, even if only one file is specified.

You can combine these options as needed. For example, head -n 10 -q file1.txt file2.txt will show the first 10 lines of both files without printing their names.

0 Comments

no data
Be the first to share your comment!