I have a list of IPs and want to run a specific curl command on each of them. The command is:

curl --user test:test | 
    egrep '@company|config.pkm.password'

And I want to run it for all IPs in IPs.txt:

1 Answer 1


You can simply iterate over each IP in your file:

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

In your case, where you want all IPs in a range, you could also simply do:

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.