シェルスクリプトでipsetにファイルを追加するには?

シェルスクリプトでipsetにファイルを追加するには?

これは私のipsetシェルスクリプトファイルです。

#!/bin/bash
for IP in $(wget -O /var/geoiptest.txt http://www.ipdeny.com/ipblocks/data/countries/{ad,ae,af}.zone)
do
# ban everything - block country
sudo ipset add geo /var/geoiptest.txt
done

最後の行に問題があるようですが、どうすれば解決できますか?

ベストアンサー1

繰り返しが間違っています。正しい構文は次のようになります。

#!/bin/bash
sudo wget -O /var/geoiptest.txt http://www.ipdeny.com/ipblocks/data/countries/{ad,ae,af}.zone
while read ip; do
    sudo ipset add geo $ip
done < /var/geoiptest.txt

おすすめ記事