The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #5 (permalink)  
Old 03-18-2008
summer_cherry summer_cherry is offline Forum Advisor  
Registered User
  
 

Join Date: Jun 2007
Location: Beijing China
Posts: 1,089

Code:
nawk 'BEGIN{RS="--";n=1;host[n]=sprintf("host,parent")}
{
n=n+1
host[n]=sprintf("%s,%s",$4,$6)
}
END{
for(i=1;i<=n;i++)
if(host[i]!=",")
print host[i]
}
' filename