BASH – List based FOR loop

 

For example, there is a file "/home/artem/IP" with IP addresses on which you want to execute a remote command, the FOR loop will look like this:

 

IP="$(cat /home/artem/IP)"

for i in $IP
do
    ssh root@$i 'hostname'
done

Tagged: Tags

Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments