2

Writing simple script where I need to take arguments IP and name from file.

list.txt:

0.0.0.0 a
0.0.0.1 a1
...

Script example:

list=$(cat list.txt)
for ip, name in list
do
    ssh $ip 
    virsh reset $name
done

What I need is correct syntax firstly to iterate through ip and then in same loop reset by name

1 Answer 1

5

You can use read here to read ip and name in 2 different varibles:

while read -r ip name; do
    ssh "$ip"
    virsh reset "$name"
done < list.txt
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.