Sed command usage

本文介绍如何使用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

 

================================================== [INFO] 正在设置信道: 6g221 (Bandwidth: 20MHz, Channel: ) 日志将保存至: /data/temp/channels_log/6G_20MHz_ch.log wl: Bad Channel sed: invalid option -- 'E' BusyBox v1.19.4 (2025-09-27 19:27:49 CST) multi-call binary. Usage: sed [-efinr] SED_CMD [FILE]... -e CMD Add CMD to sed commands to be executed -f FILE Add FILE contents to sed commands to be executed -i Edit files in-place (else sends result to stdout) -n Suppress automatic printing of pattern space -r Use extended regex syntax If no -e or -f, the first non-option argument is the sed command string. Remaining arguments are input files (stdin if none). ================================================== [INFO] 正在设置信道: 6g225 (Bandwidth: 20MHz, Channel: ) 日志将保存至: /data/temp/channels_log/6G_20MHz_ch.log wl: Bad Channel sed: invalid option -- 'E' BusyBox v1.19.4 (2025-09-27 19:27:49 CST) multi-call binary. Usage: sed [-efinr] SED_CMD [FILE]... -e CMD Add CMD to sed commands to be executed -f FILE Add FILE contents to sed commands to be executed -i Edit files in-place (else sends result to stdout) -n Suppress automatic printing of pattern space -r Use extended regex syntax If no -e or -f, the first non-option argument is the sed command string. Remaining arguments are input files (stdin if none). ================================================== [INFO] 正在设置信道: 6g229 (Bandwidth: 20MHz, Channel: ) 日志将保存至: /data/temp/channels_log/6G_20MHz_ch.log wl: Bad Channel [10028][main:1842]: weather detect ntp not sync sed: invalid option -- 'E' BusyBox v1.19.4 (2025-09-27 19:27:49 CST) multi-call binary. Usage: sed [-efinr] SED_CMD [FILE]... -e CMD Add CMD to sed commands to be executed -f FILE Add FILE contents to sed commands to be executed -i Edit files in-place (else sends result to stdout) -n Suppress automatic printing of pattern space -r Use extended regex syntax If no -e or -f, the first non-option argument is the sed command string. Remaining arguments are input files (stdin if none). ================================================== [INFO] 正在设置信道: 6g233 (Bandwidth: 20MHz, Channel: ) 日志将保存至: /data/temp/channels_log/6G_20MHz_ch.log wl: Bad Channel ✅ 所有信道测试完成!日志位于: /data/temp/channels_log 为什么报错wl: Bad Channel [10028][main:1842]: weather detect ntp not sync sed: invalid option -- 'E' BusyBox v1.19.4 (2025-09-27 19:27:49 CST) multi-call binary. Usage: sed [-efinr] SED_CMD [FILE]...
最新发布
10-31
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值