我正在尝试构建一个 shell 脚本,它将使用 while 循环读取文件(scope.txt)。范围文件包含网站域。该循环将遍历 scope.txt 文件并在另一个名为 urls.txt 的文件中搜索该域。我需要 grep urls.txt 文件中的模式,并且需要最后提到的结果。
范围文件包含 -
google.com
facebook.com
URLs 文件内容 -
https://google.com/ukhkj/sdgdsdd/
http://abcs.google.com/sdf/sg/dfg?ijkl=asffdf
https://test.com/sdvs?url=google.com
https://abcd.com/jhhhh/hghv?proxy=https://google.com
https://a.b.c.d.facebook.com/ss/sdfsdf
http://aa.b.c.d.com/dfgdfg/sgfdfg?url=https://google.com
我需要的输出 -
https://google.com/ukhkj/sdgdsdd/
http://abcs.google.com/sdf/sg/dfg?ijkl=asffdf
https://a.b.c.d.facebook.com/ss/sdfsdf
因为生成的输出包含 scope.txt 文件中提到的特定域的所有域和子域。
我试图构建一个 shell 脚本文件,但没有得到想要的输出 shell 脚本内容 -
while read -r line; do
cat urls.txt | grep -e "^https\:\/\/$line\|^http\:\/\/$line"
done < scope.txt