【发布时间】:2021-10-17 22:24:43
【问题描述】:
我有两个列表或网址
第一个listofdomains.txt 包含以下内容
http://example.com
https://www.example.com
https://abc-test.example.com
第二个urls_params.txt 包含如下
http://example.com/?param1=123
http://example.com/?param1=123¶m2=456
https://www.example.com/?param1=123
https://www.example.com/?param1=123¶m2=456
https://abc-test.example.com/?param1=123
https://abc-test.example.com/?param1=123¶m2=456
我需要在两个列表之间循环以从urls_params.txt grep 所有网址都属于每个子域并将其保存为 subdomain name.txt
例如,所需的输出是
文件名为 example.com 并包含
http://example.com/?param1=123
http://example.com/?param1=123¶m2=456
其他子域以此类推
我不起作用的解决方案是将listofdomains.txt 列表过滤为仅作为
example.com
www.example.com
abc-test.example.com
并将其保存在名为 list 的文件中
然后执行以下命令
while read -r url; do $(cat urls_params.txt | awk -v u="$url" '{print u}') ; done < list
但是输出是错误的
example.com: command not found
www.example.com: command not found
abc-test.example.com: command not found
谢谢
【问题讨论】:
-
命令替换
$(...)周围的命令没用,把它拿出来。哦,丢了uselesscat.