i made a script on my own. this is for the inventory to all of my AWS servers, and i run it to all of my servers to get the hostname, please look at file2. Then i need some data in file3 as well,. i need to combine them
Please don't modify posts that have been referred to by others! And. please apply sufficient painstakingness when writing your spec. Now it is referring to file3 which is not present anymore.
You have been reminded to use code tags on so many occasions you are on the verge of being automatically tempbanned for having so many warnings. This would have already happened, if the unix.com forum software hadn't reminded me you were close to the limit. Please use code tags!
If you are confused on the process, view this video we have prepared for your convenience.
If you can't play the video, or the button doesn't work in your browser or phone, then type them yourself -- like this.
What does "not dynamic" mean exactly?
Could you post a representative sample to capture all the cases and the desired output, please?!
---------- Post updated at 05:22 PM ---------- Previous update was at 05:17 PM ----------
I think this is what you're after:
FNR==NR {
if (NF==1) {
if (/^[0-9.]+$/)
ip=$1
if (/[a-zA-Z.]$/)
name[ip]=$1
}
next
}
NF {
ip=substr($2,index($2,".")+1)
gsub("[.][^0-9]+$","",ip)
print ip, name[ip], $1, $3
delete name[ip]
}
END {
for (i in name)
print i, name
}