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

posted @ 2014-01-10 15:30  唐僧吃肉  阅读(1424)  评论(0编辑  收藏  举报