![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Zip a folder including its sub-folders. | gdog | UNIX for Dummies Questions & Answers | 3 | 07-10-2008 04:36 PM |
| Converting Binary decimal coded values to Ascii Values | gaur.deepti | UNIX for Advanced & Expert Users | 3 | 04-02-2008 01:33 PM |
| Including files | marringi | UNIX for Dummies Questions & Answers | 1 | 04-01-2008 09:46 AM |
| Error different when including a printf | arunkumar_mca | High Level Programming | 1 | 03-12-2008 01:21 PM |
| to grep and rm including all subdirectories | annej33 | UNIX for Dummies Questions & Answers | 1 | 10-10-2000 09:18 PM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Loops (including exclusing whille values)
Is there a way to make the following script more efficient using a single loop? I want n to be 1 through 254 excluding 10 and 225. How would I go about doing that? Code:
#!/usr/local/bin/bash
nr="172.16.2."
n=1
msg="Adding static route for: "
while [ $n -le 9 ]
do
/bin/echo $msg$nr$n
/sbin/route add $nr$n -interface tun0
n=$((n+1))
done
n=11
while [ $n -le 224 ]
do
/bin/echo $msg$nr$n
/sbin/route add $nr$n -interface tun0
n=$((n+1))
done
n=232
while [ $n -le 254 ]
do
/bin/echo $msg$nr$n
/sbin/route add $nr$n -interface tun0
n=$((n+1))
done
Thanks! ![]() J. |
| Bookmarks |
| Tags |
| [solved] |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|