我想出了一个很酷的脚本,它将产生我需要的输出,但它只显示在屏幕上,所以我必须复制,然后粘贴命令以使它们执行.这是我的脚本的缩写版本:
#!/bin/bash
runc=/etc/csf/csf.pl -d
for IP in `tail -400 iptext.txt`
do
cc=`geoiplookup $IP`
echo -e $runc $IP $cc | grep Algeria
echo -e $runc $IP $cc | grep Argentina
echo -e $runc $IP $cc | grep Armenia
echo -e $runc $IP $cc | grep Azerbaijan
echo -e $runc $IP $cc | grep Bolivia
echo -e $runc $IP $cc | grep Brazil
done
Run Code Online (Sandbox Code Playgroud)
好吧,所以它遍历iptext.txt中的IP地址列表,然后对每个地址进行geoIP查找,如果(在这个例子中)列表中有两个geoIP匹配,让我们说亚美尼亚和巴西,我会看到输出像这样的shell窗口:
/etc/csf/csf.pl -d 46.162.242.17 GeoIP Country Edition: AM, Armenia
/etc/csf/csf.pl -d 200.147.38.50 GeoIP Country Edition: BR, Brazil
Run Code Online (Sandbox Code Playgroud)
这很好,但我想要的不仅仅是输出,我实际上想要 …