nixCraft Linux Forum

nixCraft

Linux Tech Support Forum

rearranging columns in a text file

This is a discussion on rearranging columns in a text file within the Shell scripting forums, part of the Development/Scripting category; Hi to all. I am new to linux. I am using redhat linux. data is like this in a text ...


Go Back   nixCraft Linux Forum > Development/Scripting > Shell scripting

Register FAQ Members List Calendar Forgotten your password? Mark Forums Read
  #1 (permalink)  
Old 12-05-2006, 10:51 AM
Junior Member
User
 
Join Date: Dec 2006
Posts: 5
Rep Power: 0
sureshbup
Default rearranging columns in a text file

Hi to all.

I am new to linux.

I am using redhat linux.

data is like this in a text file

First column second column

Ramesh , aiubghed
Ramesh , ghed
Ramesh , aiubaiub
Suresh , aghedghed
Suresh , aigheded
Suresh , aiughedhed
Kathir , aiddtghed
Kathir , ghteteed
Kathir , aiuopiiub
john , agheddlked
john , aigpqwsed
john , aidffedhed


first column having names and second column having its corresponding data..


i need a output like this


First column-Second column - Third column
Ramesh - Suresh - Kathir
aiubghed - aghedghed - aiddtghed
ghed - aigheded - ghteteed
aiubaiub - aiughedhed - aiuopiiub

and so on...

In first column uniq field should come as a heading and corresponding second column as a column.

like this i have to do for 5000 names and it corresponding values...

Is it possible to do it in awk or sed. I am new to linux. please some help ..


Thanks in advance..

with kind regards
ramesh
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 12-05-2006, 11:44 AM
monk's Avatar
Senior Member
User
 
Join Date: Jan 2005
Location: Tibet
My distro: Debian GNU/Linux
Posts: 482
Rep Power: 5
monk will become famous soon enough monk will become famous soon enough
Default

So you want unique names only. I really don't understand your output

Your INPUT
Code:
Ramesh , aiubghed
Ramesh , ghed
Ramesh , aiubaiub
Suresh , aghedghed
Suresh , aigheded
Suresh , aiughedhed
Kathir , aiddtghed
Kathir , ghteteed
Kathir , aiuopiiub
john , agheddlked
john , aigpqwsed
john , aidffedhed
Quote:
First column-Second column - Third column
Where is 3rd column?

Can u expalin how this output is related to above input?
Code:
Ramesh - Suresh - Kathir
Provides us more info so that we can sort out your problem. Yes u can use awk/sed commands for same. But give us correct details..
Reply With Quote
  #3 (permalink)  
Old 12-06-2006, 10:43 AM
Junior Member
User
 
Join Date: Dec 2006
Posts: 5
Rep Power: 0
sureshbup
Default

[quote]


result file is in two column format; first column (SHEETs,SSBONDs,CISPEPs..etc....) and second column (ASP,PHE, MET... etc)


Code:
SHEET ,MET
SHEET ,ASP
SHEET ,PHE
SHEET ,SER
SHEET ,THR
SHEET ,ALA
SHEET ,LEU
SHEET ,LEU
SHEET ,MET
SHEET ,SER
SHEET ,ALA
SHEET ,GLN
SSBOND,CYS
SSBOND,CYS
SSBOND,CYS 
SSBOND,CYS 
SSBOND,CYS 
SSBOND,CYS 
SSBOND,CYS 
SSBOND,CYS 
CISPEP,THR 
CISPEP,ALA 
CISPEP,ALA 
CISPEP,THR 
CISPEP,ALA 
CISPEP,THR 
CISPEP,ALA 
CISPEP,THR [/color]

[quote]

i have to convert  this two column type into  firt column,second column, and thirdcolumn like which i have shown below...
SHEET
MET
ASP
PHE
SER
THR
ALA
LEU
LEU
MET
SER
ALA
GLN


[quote]

Second column

[code]

SSBOND
CYS
CYS
CYS
CYS
CYS
CYS
CYS
CYS


[quote]


Third column

[code]

CISPEP
THR
ALA
ALA
THR
ALA
THR
ALA
THR



[code]

Thanks for your reply. Help me in this..


with kind regards
ramesh
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads

Thread Thread Starter Forum Replies Last Post
To find and replace in text file nashtech Shell scripting 3 07-31-2008 07:46 PM
Cups is not printing text file with proper format, staircasing issue Ashish Pathak CentOS / RHEL / Fedora 1 11-18-2007 09:12 AM
help me in editing this columns sureshbup Shell scripting 1 12-12-2006 03:29 PM
Calculations across different lines & columns of a file Guest Shell scripting 2 09-16-2005 05:18 AM
Replacing text in a file using awk postyrus Shell scripting 4 05-02-2005 04:31 PM


All times are GMT +5.5. The time now is 06:03 PM.


Powered by vBulletin® Version 3.7.4 - Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36