sed删除行及字符转义,


cat dai_cha.txt 

http://adaminsys-yangboshi.com/login?redirect=%2Fdashboard
https://front-yangbshi.com/yybs
https://pmapi-gyangboshi.com/h5/index.html#/
http://nacos.ouxuan.com/nacos/#/login
182.92.64.122:443
121.132.27.36:3317
121.132.27.36:80
121.132.27.36:8283
149.224.7.150:443
149.224.7.150:9102
149.224.7.150:9099
149.224.7.150:80
149.196.94.12:443
149.196.94.12:9102
149.196.94.12:9099
146.15.8.248:443


 cat test.txt 
http://adaminsys-yangboshi.com/login?redirect=%2Fdashboard
https://front-yangbshi.com/yybs
https://pmapi-gyangboshi.com/h5/index.html#/
http://nacos.ouxuan.com/nacos/#/login
182.92.64.122:443
121.132.27.36:3317
121.132.27.36:80
121.132.27.36:8283
149.224.7.150:443
149.224.7.150:9102
149.224.7.150:9099

at Delete_row.sh 
#!/bin/sh
set -x 

cat test.txt|while read hash
do
 sed -i '/'$hash'/d' dai_cha.txt
done


想法是 从test.txt 读取每一行的字符,如果字符在 dai_cha.txt 文件存在的,就删除 dai_cha.txt 的所在行
ip加端口的删除没有问题,但http://开头的无法删除,忘记 sed -i 删除行的是怎么转义http://的了,求帮助,谢谢!
请提供下http://行的转义字符说明,谢谢!
试过写成 sed -i '#'$hash'#d' dai_cha.txt 不行

问题原因是:这个是sed的规则式限定符和http中的/冲突
现在这个问题单独用sed处理比较麻烦,但可以利用grep工具结合-v来获取最终合理结果。
具体脚本如下:

#!/bin/bash
set -x
cat test.txt | while read hash ;do
   grep -v  ${hash}  dai_cha.txt > dai_cha.t
   cp dai_cha.t dai_cha.txt
done

将后面跟http的空格和行的其余部分替换为空:

's/ http.*//'

转义加\ 就行

sed -r "/http:\/\//d" test.txt