For loop processing list

For Loop

For loop processing list

Quick little script which processes a list of servers and executes a command on each server.

#!/bin/bash

SERVERS="server1 server2\
server3 server4 \
server5"

## YOU COULD ALWAYS do

#SERVERS=$(echo server{1..4}) ## This would also create a variable with a list of servers

for i in $SERVERS
do
  echo "going to server $i"
  ssh <username>@$i -C "cat /etc/redhat-release"
done;

Browse Space

- Pages
- News
- Labels
- Attachments
- Bookmarks
- Mail
- Advanced

Explore Confluence

- Popular Labels
- Notation Guide

Your Account

Log In

 

Other Features

Add Content

- Add Comment