Replace string using REGExpression
sed 's/<pattern>/<string/g' file
Example:
sed 's/[0-9]//g' test.txt
Remove lines
sed '/<pattern>/d' file
Example:
sed '/[^//]$/d' test.txt
本文介绍如何使用SED命令进行字符串替换及删除操作。SED是一款强大的文本编辑工具,通过正则表达式匹配模式并进行替换,适用于去除特定字符或删除不符合条件的整行。文中举例展示了如何从文件中移除所有数字字符及如何删除以特殊符号结尾的行。
Replace string using REGExpression
sed 's/<pattern>/<string/g' file
Example:
sed 's/[0-9]//g' test.txt
Remove lines
sed '/<pattern>/d' file
Example:
sed '/[^//]$/d' test.txt
351

被折叠的 条评论
为什么被折叠?