Operating System - Linux
1753331 Members
5130 Online
108792 Solutions
New Discussion юеВ

Re: how to increment a number

 
SOLVED
Go to solution
Justin_99
Valued Contributor
Solution

Re: how to increment a number

Generate the list pretty quick with this.
Just change the -le 150 to the last IP number i used 150 as example, and change xx.xx as well.

hou00us:~> i=0; while [ $i -le 150 ]; do printf "10.xx.xx.%d\n" $i ;i=`expr $i + 1`; done


10.xx.xx.0
10.xx.xx.1
10.xx.xx.2
10.xx.xx.3
10.xx.xx.4
10.xx.xx.5
10.xx.xx.6
10.xx.xx.7
10.xx.xx.8
10.xx.xx.9
10.xx.xx.10
<<>>
10.xx.xx.150
skt_skt
Honored Contributor

Re: how to increment a number

c=0;
command|while read a
do
((c=c+$a))
done
Mike Stroyan
Honored Contributor

Re: how to increment a number

Charles,
If you use bash shell you can use a for loop
very similar to C language syntax

for ((i=1; i<=100; i++))
do
echo $i
done
Yogeeraj_1
Honored Contributor

Re: how to increment a number

hi Charles,

below an example of the nmap output:
=========================================
# nmap -sP 1.2.3.0/24
Starting nmap 3.70 ( http://www.insecure.org/nmap/ ) at 2007-07-23 09:14 MUT
Host 1.2.3.0 seems to be a subnet broadcast address (returned 10 extra pings). Note -- the actual IP also responded.
MAC Address: 00:0E:38:6F:FB:00 (Cisco Systems)
Host 1.2.3.1 appears to be up.
MAC Address: 00:03:6B:A7:0A:60 (Cisco Systems)
Host 1.2.3.2 appears to be up.
MAC Address: 00:17:E0:7E:98:96 (Unknown)
Host 1.2.3.3 appears to be up.
MAC Address: 00:0F:F7:16:1F:1E (Cisco Systems)
Host 1.2.3.4 appears to be up.
MAC Address: 00:0F:F7:16:1F:22 (Cisco Systems)
Host 1.2.3.5 appears to be up.
MAC Address: 00:11:85:F9:49:7A (Unknown)
Host 1.2.3.6 appears to be up.
MAC Address: 00:0E:38:50:97:80 (Cisco Systems)
Host 1.2.3.7 appears to be up.
MAC Address: 00:12:79:CF:55:ED (Unknown)
Host 1.2.3.8 appears to be up.
MAC Address: 00:12:79:CF:56:9F (Unknown)
Host 1.2.3.9 appears to be up.
MAC Address: 00:12:79:CF:55:ED (Unknown)
...
Host 1.2.3.251 appears to be up.
MAC Address: 00:16:17:5D:07:31 (Unknown)
Host 1.2.3.252 appears to be up.
MAC Address: 00:16:17:5C:EA:5C (Unknown)
Host 1.2.3.253 appears to be up.
MAC Address: 00:0C:29:74:2E:79 (VMware)
Host 1.2.3.254 appears to be up.
MAC Address: 00:0E:38:6F:FB:00 (Cisco Systems)
Host 1.2.3.255 seems to be a subnet broadcast address (returned 13 extra pings). Note -- the actual IP also responded.
MAC Address: 00:0E:38:6F:FB:00 (Cisco Systems)
Nmap run completed -- 256 IP addresses (167 hosts up) scanned in 6.706 seconds

=========================================

See if this is acceptable else we will have to work it out using scripts!

kind regards
yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)
Charles Holland
Trusted Contributor

Re: how to increment a number

situation resolved, Thanks to all who answered the call.

Thanks.
"Not everything that can be counted counts, and not everything that counts can be counted" A. Einstein
Charles Holland
Trusted Contributor

Re: how to increment a number

Done.
"Not everything that can be counted counts, and not everything that counts can be counted" A. Einstein