Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 06-20-2012
Registered User
 
Join Date: May 2011
Posts: 6
Thanks: 2
Thanked 0 Times in 0 Posts
Appending columns at the end of output using awk/sed

Hi ,

I have the below ouput,


Code:
=====gopi=====
assasassaa
adsadsadsdsada
asdsadsadasdsa
sadasdsadsd
=====kannan===
asdasdasd
sadasddsaasd
adasdd
=====hbk===
asasasssa
....
..

I want the output like as below, not able paste here correctly.


Code:
=====gopi===== =====kannan=== =====hbk===
assasassaa asdasdasd asasasssa
adsadsadsdsada sadasddsaasd 
asdsadsadasdsa adasdd 
sadasdsadsd


Last edited by Scrutinizer; 06-20-2012 at 07:17 AM.. Reason: code tags
Sponsored Links
    #2  
Old 06-20-2012
elixir_sinari's Avatar
Gotham Knight
 
Join Date: Mar 2012
Location: India
Posts: 1,372
Thanks: 87
Thanked 478 Times in 458 Posts
Try

Code:
awk '/^=/ {
 i=1
 a[i]==""?a[i]=$0:a[i]=a[i]"\t"$0
} 
!/^[=]/ {
 i++
 a[i]==""?a[i]=$0:a[i]=a[i]"\t"$0
}
END{i=1;while(a[i] != ""){print a[i];i++}}' inputfile


Last edited by elixir_sinari; 06-20-2012 at 08:36 AM..
The Following User Says Thank You to elixir_sinari For This Useful Post:
eeegopikannan (06-20-2012)
Sponsored Links
    #3  
Old 06-20-2012
Registered User
 
Join Date: May 2011
Posts: 6
Thanks: 2
Thanked 0 Times in 0 Posts
Thanks it worked. Its too good to see in excel sheet.
Thanks again
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Appending columns of two files using shell script siri_886 Shell Programming and Scripting 1 12-22-2010 09:59 AM
Appending sed output to variable jazzaddict UNIX for Dummies Questions & Answers 5 10-24-2010 11:34 AM
appending several columns with awk and paste creamcheese Shell Programming and Scripting 2 07-03-2009 11:27 AM
Appending the last few columns to the front ragavhere Shell Programming and Scripting 3 07-08-2008 09:11 AM
Appending columns on a file abel Shell Programming and Scripting 2 09-27-2002 07:04 AM



All times are GMT -4. The time now is 01:58 AM.