troubleshooting Question

Help with script (sh)

Avatar of sda100
sda100Flag for United Kingdom of Great Britain and Northern Ireland asked on
LinuxLinux Distributions
4 Comments3 Solutions534 ViewsLast Modified:
I'm trying to write a script (using sh) that will create dhcp.conf from a list of data.  The part which I'm getting stuck on is how to specify a subnet range.  Using Bash, the (( a=1, a<10, a++)) syntax works, but not in sh.  Is there an equivalent way?

I was thinking about working from an IP address range specified like:

I can easily split this up using DOS batch language, but I don't know how to using sh.  My intention is to (with the exception of 0 and 255), search a file for each IP address, and if found, construct the relevant information for dhcp.conf.  I can even accept just writing the variables in the program rather than trying to parse those lines, but I still don't know how to loop through each IP address:

This is how I would do it in bash.  BUT can it be done in sh?

   for (( a=44; a<46; a++)); do
      for ((b=1; b<255; b++)); do
          echo 10.1.$a.$b

The alternative is to not use sh at all.  But I wanted to because I thought it was 'standard' as far as shell scripting goes.  Am I mistaken here... ie. is 'bash' seen as standard and pretty much guaranteed to be installed on any system?

Many thanks,
Steve :)

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 3 Answers and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 3 Answers and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros