I need to convert the following file example 1 to the file as appears on example 2
so it will print machine name and IP but only in case "name" appears before host_name
- redhat03.rdns.com 10.10.29.66 not printed because "name" not appears before host_name
please advice what is the best way to do this convertion by awk or sed or perl one liners
example1
"name" : "REDHAT",
"host_name" : "linux01.rdns.com",
"ip" : "10.10.29.61"
"name" : "REDHAT",
"host_name" : "linux02.rdns.com",
"ip" : "10.10.29.62"
"name" : "REDHAT",
"host_name" : "linux03.rdns.com",
"ip" : "10.10.29.63"
"name" : "REDHAT",
"host_name" : "redhat01.rdns.com",
"ip" : "10.10.29.64"
"name" : "REDHAT",
"host_name" : "redhat02.rdns.com",
"ip" : "10.10.29.65"
"name" : "REDHAT",
"host_name" : "redhat03.rdns.com",
"ip" : "10.10.29.66"
"host_name" : "redhat04.rdns.com",
"ip" : "10.10.29.67"
"name" : "REDHAT",
"host_name" : "redhat05.rdns.com",
"ip" : "10.10.29.68"
"name" : "REDHAT",
"host_name" : "redhat06.rdns.com",
"ip" : "10.10.29.81"
"name" : "REDHAT",
"host_name" : "redhat07.rdns.com",
"ip" : "10.10.29.82"
"name" : "REDHAT",
"host_name" : "redhat08.rdns.com",
"ip" : "10.10.29.83"
"name" : "REDHAT",
"host_name" : "redhat09.rdns.com",
"ip" : "10.10.29.84"
expected results
linux01.rdns.com 10.10.29.61
linux02.rdns.com 10.10.29.62
linux03.rdns.com 10.10.29.63
redhat01.rdns.com 10.10.29.64
redhat02.rdns.com 10.10.29.65
redhat03.rdns.com 10.10.29.66
redhat05.rdns.com 10.10.29.68
redhat06.rdns.com 10.10.29.81
redhat07.rdns.com 10.10.29.82
redhat08.rdns.com 10.10.29.83
redhat09.rdns.com 10.10.29.84
redhat04.rdns.com
is not printed – RomanPerekhrest Jan 9 '18 at 14:02