Programifications

A mashup of technical quirks

For Loops in the Terminal

| Comments

Recently I’ve had to retrieve information from a set of remote servers. Using the for loop in the terminal, I was able to get all the information I needed in one line which was very convenient. I used the following code snippet:

1
for i in 1 2 3 4 5 6 7 8; do echo "search$i"; ssh root@search$i 'ls -alhrt /ip/sphinx_index/production'; done

Comments