- Linux Shell Scripting Cookbook(Third Edition)
- Clif Flynt Sarath Lakshman Shantanu Tushar
- 99字
- 2021-07-09 19:46:35
Using head and tail for printing the last or first 10 lines
When examining a large file, thousands of lines long, the cat command, which will display all the line,s is not suitable. Instead, we want to view a subset (for example, the first 10 lines of the file or the last 10 lines of the file). We may need to print the first n lines or last n lines or print all except the last n lines or all except the first n lines, or the lines between two locations.
The head and tail commands can do this.