Hi guys,

I am Brazillian and i don't know how to speak english very well, but, let's to the question:

I need a solution to automatically write a sequence of number to a file, for example, to write automatically to a file the number 1 at 254, this is what i need to create a address list to use with a IP firewall,

Thanks for all and sorry for the gramatical errors.

Hello modesto916,

could you please provide some more details?
It is a little bit hard to figure out exactly what you are asking for.

Well, just guessing, but as a starting point let me assume
having a file with incomplete IP addresses in a file called "iplist":

cat iplist

192.168.0.
192.168.0.
192.168.0.
192.168.0.
192.168.0.
192.168.0.
192.168.0.

Now If you want continuous and complete IP adresses just try

awk '{ print $0 NR }' iplist

which should print on stdout:

192.168.0.1
192.168.0.2
192.168.0.3
192.168.0.4
192.168.0.5
192.168.0.6
192.168.0.7

Apologizes for most likely being totally wrong.
You might want to show a sample input file
and how the result[s] should look alike?

Kind regards,
issue9

Nice issue9!

I'd probably use 'seq' to generate those numbers personally. Something like this: seq 1 254 To generate a list of IPs like in issue's example: for i in $(seq 1 254); do echo "192.168.0.$i"; done You've probably got a solution by now, but I hope this helps somebody!

-G

Edited 6 Years Ago by JeoSaurus: n/a

This article has been dead for over six months. Start a new discussion instead.