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
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