0

I use a script on my personal server to setup a few things, and I'm a bit lazy. So instead of doing every command by hand etc I got this script:

#!/bin/bash
sshservers=(IP IP IP IP)
for sshserver in "${sshservers[@]}"
        do
        ssh root@$sshserver 'Foo Bar'
done
echo "done"
exit

So it takes the servers from the variable in sshservers=. But I want it to take the IP's from a file called "servers.txt". Though when using

sshservers=$(cat servers.txt)

This doesn't work. I have to manually insert it directly in the script. How can I use the variable from a text file?

Thanks in advance!

Florius
  • 367
  • 1
  • 5
  • 17

0 Answers0