怎么通过你shell脚本删除文件的某一行以及后面几行

2025-04-15 21:57:17
推荐回答(1个)
回答1:

#!/bin/sh
myfile=test.txt
startLine=3
lineCnt=4
let endLine="startLine + lineCnt - 1"
sed -i $startLine','$endLine'd' $myfilestartLine
表示开始行的行号
lineCnt
表示总共要删除的行数