shell脚本学习 (9) 提取开头或结尾的几行

1 提取开头的n行

用head awk或者 sed实现

head -n 1 do.txt 

sed 1q do.txt

awk 'FNR <= 1' do.txt

do.txt文件

2 显示行尾的几行

 用tail -n file

tail -1 do.txt

原文地址:https://www.cnblogs.com/mayplestory/p/11995882.html