Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I use shell scripting to append a range of IPs to a file?

share|improve this question

closed as not a real question by mailq, Chris S, MDMarra, MadHatter, andol Nov 10 '11 at 19:40

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

Yes you can. echo "" >> /path/to/file. – mailq Nov 10 '11 at 19:13
Oh, or do you need it that way? echo 192.168.0.{0..255} >> /path/to/file – mailq Nov 10 '11 at 19:25
Please, classes don't exist from eons. You are referring to a /24. – ata Nov 10 '11 at 19:30

Try something like:


for i in {0..255}
    echo 192.168.0.$i >>outfile.txt

The >> operator is used to append to a file.

share|improve this answer
Thank you so much!! ps.: I know I should have found it out by myself, but I know next to nothing about shell scripting, and was (am) dead tired after adding the whole /24 range by hand in a web console (Apache/Tomcat). I'll try not to ask stupid questions next time! – neotobe Nov 10 '11 at 22:07

Not the answer you're looking for? Browse other questions tagged or ask your own question.