跳至内容
sdvcrx's wiki
用户工具
登录
站点工具
搜索
工具
显示页面
过去修订
Export to Markdown
反向链接
最近更改
媒体管理器
网站地图
登录
>
最近更改
媒体管理器
网站地图
您的足迹:
linux:sed
本页面只读。您可以查看源文件,但不能更改它。如果您觉得这是系统错误,请联系管理员。
====== Sed ====== [[wp>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:>[[http://stackoverflow.com/a/6022431|bash tool to get nth line from a file]])] sed -i "${NUM}q;d" file ==== Create backup file ==== Directly modify file and create a backup file: sed -i.bak 's/test/ok/g' file ===== Reference ===== * https://www.gnu.org/software/sed/manual/sed.html * http://www.grymoire.com/Unix/Sed.html * https://www.digitalocean.com/community/tutorials/the-basics-of-using-the-sed-stream-editor-to-manipulate-text-in-linux
linux/sed.txt
· 最后更改: 2023/12/03 10:24 由
127.0.0.1
页面工具
显示页面
过去修订
反向链接
Export to Markdown
回到顶部