删除第5行到最后一行(含第五行) sed '5,$d' -i text.txt 删除前: 删除后: sed -i '$d' a.txt # 删除最后一行 sed -i '5,$d' a.txt #删除第五行到最后一行(包含第五行) 删除前ÿ