To display a specific number of lines from a file in Linux, you can use the head or tail commands with the -n option. Here’s how to use both:
Using head
To display the first n lines of a file:
head -n <number_of_lines> filename.txt
For example, to display the first 5 lines:
head -n 5 filename.txt
Using tail
To display the last n lines of a file:
tail -n <number_of_lines> filename.txt
For example, to display the last 10 lines:
tail -n 10 filename.txt
Replace <number_of_lines> with the desired number of lines you want to display and filename.txt with the name of your file.
