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 -->
  #1 (permalink)  
Old 04-22-2009
pinnacle pinnacle is offline
Registered User
  
 

Join Date: Apr 2009
Posts: 182
Awk 2 lines to 1 line

Input File:

Quote:
Input:
host1 server1
database1 5
host2 server2
database2 5
host3 server3
database3 5
Required Result:
Quote:
host1 server1 database1 5
host2 server2 database2 5
host3 server3 database3 5
I have tried the following code:
Code:
nawk '{for(i=1; i<=NR; i+2) {print NR,$0; getline ;print \n $0; NR=NR+2}}' temp
But doesnt gives the right result.
Help is appreciated