to cover all the different scenarios i need to take my origional post(
http://www.linuxquestions.org/questi...a-file-806382/ ) a level higher. using the ip address of 4th line in FileA with the CIDR using the following code: ( thanks to grail)
Quote:
ipbits=$(ifconfig eth0 | awk -F: 'NR==2{print | "whatmask "$NF}' | awk -F"[ ]*:[ ]*" '/CIDR/{print $2}')
|
FileA contains:
Quote:
#this a comment
#this a comment
#this a comment
hostname 10.176.20.254
hostname 10.18.13.253
hostname 10.18.16.253
hostname 177.23.56.58
#this a comment
|
I need to use whatmask program with ip address of the 4th line (ex: 10.176.20.254) with CIDR get the Network Address & direct only ip address to a file. here is an example:
Quote:
$ whatmask 10.176.20.254/20
------------------------------------------------
TCP/IP NETWORK INFORMATION
------------------------------------------------
IP Entered = ..................: c
CIDR = ........................: /20
Netmask = .....................: 255.255.240.0
Wildcard Bits = ...............: 0.0.15.255
------------------------------------------------
Network Address = .............: 10.176.16.0
Broadcast Address = ...........: 10.176.31.255
Usable IP Addresses = .........: 4094
First Usable IP Address = .....: 10.176.16.1
Last Usable IP Address = ......: 10.176.31.254
|
so i need only below line diected to a file. (from Network Address)
10.176.16.0
thanks for your help.