As of now I have two questions but I will have a few more questions once these two have been resolved.
1. First how can I make the script output like this
instead of this? Where the rows of information get chopped up into separate rows which I don't want.
2. Second question how can I control the spacing better between Number count and Machine name?
Without doing like this? Is there a cleaner and smarter way to do the same spacing control?
.................................................
loop_uptime.sh
machines.txt
1. First how can I make the script output like this
1 Machine 1 2 Machine 2 3 Machine 3
instead of this? Where the rows of information get chopped up into separate rows which I don't want.
$ bash loop_uptime.sh 1 Machine 2 1 3 Machine
2. Second question how can I control the spacing better between Number count and Machine name?
Without doing like this? Is there a cleaner and smarter way to do the same spacing control?
echo $n \ \ \ \ \ \ \ $host
.................................................
loop_uptime.sh
#!/bin/bash
n=0
LIST=$(cat ./machines.txt)
for host in $LIST; do
let n++
echo $n $host
if [ "$n" = "3" ]; then
break
fi
done
machines.txt
Machine 1 Machine 2 Machine 3 Machine 4 Machine 5 Machine 6 Machine 7 Machine 8 Machine 9 Machine 10 Machine 11 Machine 12 Machine 13 Machine 14 Machine 15