指定位置后插入行
sed -i '/match reg/a\line1\nline2' target.txt
指定位置前插入行
sed -i '/match reg/i\line1\nline2' target.txt
指定位置后插入行
sed -i '/match reg/a\line1\nline2' target.txt
指定位置前插入行
sed -i '/match reg/i\line1\nline2' target.txt
转载于:https://www.cnblogs.com/liudebo/p/9441485.html