区间截取 文件

确定启示位置

-bash-4.1$ startpos=`awk '/P355USG/{ print NR; exit }' file1`
-bash-4.1$ startpos=`expr $startpos - 1`

 

确定结束位置

-bash-4.1$ endpos=`awk '/USG/{ print NR; }' file1 | tail -1`
-bash-4.1$ endpos=`expr $startpos + 3`

 

截取中间记录

sed -n "${startpos},${endpos}p" file1

 

posted @ 2020-01-06 18:52  kakaisgood  阅读(162)  评论(0编辑  收藏  举报