用户工具

站点工具


linux:sed

这是本文档旧的修订版!


Sed

sed, a stream editor.

Usage

Replace

Replace word with words from file:

sed -i 's|word|words' file

Replace multiple target (sperate with ;):

sed -i 's|word|words;s|hello|bye' file

Delete

Delete lines contain import:

sed -i '/import/d' file

Delete lines contain import and the next line:

sed -i '/import/,+1d' file

Delete specify line by line number [(cite:>bash tool to get nth line from a file)]

sed -i "${NUM}q;d" file

Reference

linux/sed.1492942770.txt.gz · 最后更改: 2023/12/03 10:24 (外部编辑)