head和tail命令-----得到头尾N行或者这去掉尾头N/N-1行

[algo@localhost tmp]$ cat test 
1
2
3
4

5


head得到头部2行,删掉尾部2行

[algo@localhost tmp]$ head -n +2 test 
1
2
[algo@localhost tmp]$ head -n -2 test 
1
2
3


得到尾部2行,删掉头部1(n-1)行
[algo@localhost tmp]$ tail -n 2 test 
4
5

[algo@localhost tmp]$ tail -n +2 test 
2
3
4
5

原文地址:https://www.cnblogs.com/catkins/p/5270512.html