sed line range, all but the last line

前端 未结 5 1049
小蘑菇
小蘑菇 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:08

    I know it is not sed, but I feel that head gets the easiest and most flexible way:

    head -n -1 the-file
    

    Use -2, -3... instead of -1, to retrieve all but the last two lines, etc.

提交回复
热议问题