随笔记录:linux正则小技巧col -b

当我们的文件中有很多多姿多彩的字符串或类似^M这样的退格符时,正则匹配变得困难.
此时只需加一个管道命令col -b 就可以去除退格符进行匹配
比如:
cat reports.txt | col -b |grep -o 'http.*' > newreports.txt
(将afrog的结果重定向到文件后可以用此方法匹配url)

顺带一个afrog自动双向重定向并生成检测到漏洞的url的脚本

echo $@
echo ---------------
file="afrg_rpt$(date +'%Y-%m-%d-%H-%M-%S')"
./afrog $* | tee "1$file"
cat "1$file" | col -b |grep -o 'http.*' >"$file"
rm "1$file"

最近才学bash脚本,这玩意真有意思哈

posted @ 2024-07-05 01:00  sesmof  阅读(26)  评论(0)    收藏  举报