Re: [SLUG] better way to consolidate shell commands

From: Daniel MacLaren (daniel.maclaren@gmail.com)
Date: Thu Aug 19 2004 - 16:25:23 EDT


On Thu, 19 Aug 2004 15:36:38 -0400, Levi Bard <levi@bard.sytes.net> wrote:
> ---------
> #!/bin/sh
> # Prints out a string showing what commands would be run if a command
> # (given as command line argument) were to be run on every machine in a
> given range via ssh
>
> i=0
> max=123
>
> while test "$i" -lt "${max}"
> do
> echo "exec ssh user@192.168.3.$i \"$@\""
> i=`expr "$i" + 1`
> done
> ---------
>

If you are using bash, you can also use:

i=$((i+1))

or

let i=i+1

These expressions are internal to the shell, so you are not exec'ing
the external program "expr". This is faster, but you might not notice
it in a script like this.

-Daniel
-----------------------------------------------------------------------
This list is provided as an unmoderated internet service by Networked
Knowledge Systems (NKS). Views and opinions expressed in messages
posted are those of the author and do not necessarily reflect the
official policy or position of NKS or any of its employees.



This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 15:00:45 EDT