Computing.Net > Forums > Linux > rearranging columns

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

rearranging columns

Reply to Message Icon

Name: sureshbup
Date: October 30, 2006 at 22:24:08 Pacific
OS: Red Hat Enterprise Linux
CPU/Ram: 1 GB
Product: Hpxw4200
Comment:

Hi to all.

I am new to linux. I have a csv file like this

"21","Ramesh","5","aiubghed"
"21","Ramesh","4","ghed"
"21","Ramesh","0","aiubaiub"
"21","Suresh","5","aghedghed"
"19","Suresh","A","aigheded"
"19","Suresh","A7","aiughedhed"

i need the output like this

Ramesh , suresh
aiubghed , aghedghed
ghed , aigheded
aiubaiub , aiughedhed

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


regards
ramesh



Sponsored Link
Ads by Google

Response Number 1
Name: nails
Date: November 2, 2006 at 09:19:36 Pacific
Reply:

I can not see any pattern. Can you explain?

Maybe this will get you started; this command:

tr -d \" < csv.file|nawk ' BEGIN { FS="," } { printf("%s , %s\n", $2, $4) } '

delivers this output - printing the 2nd and 4th fields:

Ramesh , aiubghed
Ramesh , ghed
Ramesh , aiubaiub
Suresh , aghedghed
Suresh , aigheded
Suresh , aiughedhed



0

Response Number 2
Name: sureshbup
Date: November 2, 2006 at 22:17:11 Pacific
Reply:

Thankyou very much for your reply.

data is like this

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

i need output like


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


like that for fourth.

Fourth column
john
agheddlked
aigpqwsed
aidffedhed

I can't able to align columns properly here. so i have differentiated columns with hypen(-)



0

Response Number 3
Name: nails
Date: November 3, 2006 at 07:27:00 Pacific
Reply:

Sorry, but I still see no pattern to your output. I can not help. Perhaps you can explain.


0

Response Number 4
Name: sureshbup
Date: November 6, 2006 at 21:23:46 Pacific
Reply:

Hi , i don't find any pattern in my file. But if pattern is there how can we able to extract.

Suppose to be like this

Ramesh , abcd1
Ramesh , abcd2
Ramesh , abcd3
Suresh , abcd0
Suresh , abcd5
Suresh , abcd6
Kathir , abcd7
Kathir , abcd8
Kathir , abcd0
john , abcd1
john , abcd3
john , abcd7.


Thanks for reply.It will be very much helpful to me, if u can help me in this.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Linux Forum Home


Sponsored links

Ads by Google


Results for: rearranging columns

Grep and removing columns www.computing.net/answers/linux/grep-and-removing-columns/27799.html

No such file in Redhat 9 www.computing.net/answers/linux/no-such-file-in-redhat-9/20455.html

Word documents and wp8 www.computing.net/answers/linux/word-documents-and-wp8/240.html