Your output data doesn't really resemble your input. It seems to create .79, .1, .2 out of nowhere -- how does it decide these from .0? Why does it ignore 10.26.208.0? etc, etc.
You'll have to explain the algorithm you want better.
Thanks for the reply, Let me rephrase my question. I need to get the interface name (example en2 -> private en5 -> private en6 -> public)based on those below input file and get the ipaddress for each interface name..... like that i have to do for each line of input file... and get the output as below.
Input data (Only single line) is generated by oracle database itself its stored in config file in each and every Oracle RAC Server as below format
ex:
if we specify one public & private interface during installation of oracle RAC it will put one entry for public and private as below format in config file
"<interfacename>"/<subnet>:public,"<interfacename>"/<subnet>:cluster_interconnect
if we specify one public & two private interface during installation of oracle RAC it will put one entry for public and two private as below format in config file
"<interfacename>"/<subnet>:public,"<interfacename>"/<subnet>:cluster_interconnect,"<interfacename>"/<subnet>:cluster_interconnect
All i am doing now is based on this input stored in the config file i want to convert this to below output
EX : ifconfig en2 (Ipaddress will be derived from this command)
en6 -> public -> <Ipaddress>
en2 -> Private 1 -> <Ipaddress>
en5 -> Private 2 -> <Ipaddress>
Making the wild assumption (amongst others) that your ifconfig will produce sth like
eth0 Link encap:Ethernet HWaddr 00:1f:c6:4c:d0:e2
inet addr:10.1.1.1
this awk program (saved in cmdfile) might do the job:
BEGIN {
while (("ifconfig -a|awk '/Link/ {a=$1; getline; sub(\".*:\",\"\",$2);print a, $2}'"|getline) > 0)
ip[$1]=$2
RS="[,\n]"; FS="/"
}
{
gsub("\"","");gsub("([0-9]+[.:])+","",$2); if($2!="public") $2="Private "++pn
}
{print $1, "->", $2, "->", ip[$1]}
Execute like awk -f cmdfile inputfile
What it does is in the BEGIN command it executes ifconfig to pipe all the interfaces (identified by "Link" in the same line) and their IP- addresses into array "ip". Then it reads your input file, records separated by ",", to extract the respective interface names, cleans field $2 from the network part, and, if the remainder is not "public", assigns the string "Private " plus a counter. Finally the fields are printed. Hope this fits your needs. You may need to adapt the ifconfig extraction.