The UNIX and Linux Forums  

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




Thread: awk help
View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #6 (permalink)  
Old 05-26-2009
devtakh devtakh is offline
Registered User
  
 

Join Date: Oct 2007
Location: Bangalore
Posts: 514

Code:
 awk '
NR==1{p1=$1;p2=$2;getline;printf("(%s-%s)%s(%s-%s)\n",p1,$2,OFS,p2,$1);q1=$1;q2=$2;next}
{printf("(%s-%s)%s(%s-%s)\n",q1,$2,OFS,q2,$1);q1=$1;q2=$2}' file


-Devaraj Takhellambam