The head command in Unix-like systems is used to display the beginning of a text file or the output of a command. By default, it shows the first 10 lines of the specified file or input. Here are some key differences and features of head:
-
Output Control: You can specify the number of lines to display using the
-noption. For example,head -n 5 filename.txtshows the first 5 lines. -
Input from Pipes:
headcan take input from other commands via pipes. For example,ls -l | headwill show the first 10 lines of the output from thels -lcommand. -
File Handling: You can use
headwith multiple files. For example,head file1.txt file2.txtwill display the first 10 lines of each file, with a header indicating the file name.
In contrast, the whoami command is specifically for displaying the current user's username, while head is focused on file content management. If you need more details or examples, let me know!
