sed line range, all but the last line

前端 未结 5 1045
小蘑菇
小蘑菇 2020-12-08 04:48

You can specify a range of lines to operate on. For example, to operate on all lines, (which is of course the default):

sed -e \"1,$ s/a/b/\"
5条回答
  •  情深已故
    2020-12-08 05:15

    sed -e "$ ! s/a/b/"
    

    This will match every line but the last. Confirmed with a quick test!

提交回复
热议问题