开发者

Delete every seventh line using sed

I need a sed script that deletes every seventh line in a file. I managed to do this with an awk开发者_开发百科 script but wanted to look for a way to use sed to do this.


You can try

sed 'n;n;n;n;n;n;d;' 


Sai solution seems to be the best one. However, if you are using GNU sed and does not look for portability, you can use the step address:

$ seq 1 10 | sed '0~3d'
1
2
4
5
7
8
10

The n~m address matches all k-th line where k = n+m*i.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜