LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-08-2012, 01:43 AM   #1
naveenchandar
LQ Newbie
 
Registered: Nov 2012
Posts: 2

Rep: Reputation: Disabled
Question Script to convert words in a text file [columns to rows]


I have a text file

cat test

owner status log name
MIS Failed sop rose
MIS Failed sop lilly
MIS Failed sop lotus

the output should be

owner : MIS,MIS,MIS
status : Failed,Failed,Failed
log : sop,sop,sop
name : rose,lilly.lotus
 
Old 11-08-2012, 01:59 AM   #2
angel115
Member
 
Registered: Jul 2005
Location: France / Ireland
Distribution: Debian mainly, and Ubuntu
Posts: 528

Rep: Reputation: 78
Hello,

I'll not make this script for you for 2 reasons:
- first I don't have the time
- second this is not helping to do the job for you, as if I do so you will not learn

But here is how I would do this
1- create a script (bash would do the job)
2- extract each column and store them in an array (ex: awk < test '{ print $1 }') $2, $3, etc... for the next columns
3- write these arrays in a file.

Good luck

Last edited by angel115; 11-18-2012 at 02:23 PM.
 
Old 11-08-2012, 02:00 AM   #3
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
Show us your code.

You will find these useful
http://rute.2038bug.com/index.html.gz
http://tldp.org/LDP/Bash-Beginners-G...tml/index.html
http://www.tldp.org/LDP/abs/html/
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] How to convert the rows of data into the columns? w1k0 Programming 101 02-06-2014 10:24 PM
Convert columns of data into rows jaufer Linux - Software 3 06-29-2010 06:19 PM
convert columns to rows (tab separated file to csv) doug23 Programming 16 08-16-2009 10:14 PM
Script to convert logs columns to rows fono Linux - Software 10 05-19-2009 09:29 PM
text data conversion: rows into columns frankie_DJ Programming 6 06-03-2006 07:43 AM


All times are GMT -5. The time now is 10:31 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration