カールはテキストファイルからIPをロードします。

カールはテキストファイルからIPをロードします。

IPリストがあり、curl各IPで特定のコマンドを実行したいと思います。コマンドは次のとおりです。

curl --user test:test http://192.168.1.1/security/pkm.html | 
    egrep '@company|config.pkm.password'

次のすべてのIPに対して実行したいと思いますIPs.txt

192.168.1.1
192.168.1.2
192.168.1.3
........1.200

ベストアンサー1

ファイルの各IPを簡単に繰り返すことができます。

while read IP; do 
    curl --user test:test http://"$IP"/security/pkm.html | 
        egrep '@company|config.pkm.password'
done < IPs.txt

あなたの場合、特定の範囲のすべてのIPが必要な場合は、単に次のことを行うこともできます。

for i in {1..200}; do
    curl --user test:test http://192.168.1."$i"/security/pkm.html | 
        egrep '@company|config.pkm.password'
done

おすすめ記事