目录 问题背景: 解决方法: 问题背景: lable_A: 待提取的数据 lable_B: 解决方法: 1.查找文件中指定关键字所在的行 cat -n file | grep 'Keyword' 2.取该行的行号赋值给变量num num=`cat file | grep -n 'keyword'` 3.以改行为基准上下偏移,比如num=10,可以取num+5,就是10-15行之间的数据 cat file | sed -n "$num,$(($num+5))p"