rearranging the data in file (from columnwise to rowwise)


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting rearranging the data in file (from columnwise to rowwise)
# 1  
Old 01-25-2007
rearranging the data in file (from columnwise to rowwise)

Hi

I have one file which is having data like


10201 10202 10205 10206 10207 10208 10209 10210 10211 10213 10215

10801 10802



11406 11415 11422 11426
11513 11514 11515 11516 11517 11518 11519 11520 11521 11522 11523 11524 11525 11530
11604 11608 11611
11717 11718 11719 11722 11725 11726 11727 11728 11729 11730 11731 11732 11736


some line are having 5 fields are some 10 means it is not fix some lines are empty

I want to rearrange this file so that each line is having only one field

eg
11717
11718
11719
11712

etc

how can i do this ?
# 2  
Old 01-25-2007
pls be more specific
# 3  
Old 01-25-2007
Code:
tr -s '[:blank:]' '\n' < file

# 4  
Old 01-26-2007
Quote:
Originally Posted by reldb
I have one file which is having data like


10201 10202 10205 10206 10207 10208 10209 10210 10211 10213 10215

10801 10802



11406 11415 11422 11426
11513 11514 11515 11516 11517 11518 11519 11520 11521 11522 11523 11524 11525 11530
11604 11608 11611
11717 11718 11719 11722 11725 11726 11727 11728 11729 11730 11731 11732 11736


some line are having 5 fields are some 10 means it is not fix some lines are empty

I want to rearrange this file so that each line is having only one field

eg
11717
11718
11719
11712

etc
Or, without external commands, if your shell has the "printf" builtin
(for example if you use shell, other than sh):

Code:
printf "%s\n" $(<file)

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Rearranging Data Set

Hello everybody, I've got the following problem: The data set I have is an ASCII file containing a header over 4 lines and the actual data comprised of dezimal numbers in a 1000x1000 grid (1000 lines and 1000 columns). Since I want to plot the data in GMT I need to convert it into the... (3 Replies)
Discussion started by: Evilknievel
3 Replies

2. Shell Programming and Scripting

Help with rearranging file with script

Hi Guys I normally do thins with a Windows program but I am trying to rearrange a filename based on delimiters in Ubuntu. Example v017 __ Detective Academy Q #133 Murder in the Village Of Suspension Bridges &&& Part 9.cbz = Detective Academy Q v017 #133 Murder in the Village Of Suspension... (9 Replies)
Discussion started by: itschrisonline
9 Replies

3. Shell Programming and Scripting

Data rearranging from rows to column

Hello Everyone, I have a input file looks like -0.005-0.004-0.003-0.002-0.00100.0010.0020.0030.0040.005My desired output should look like -0.005 -0.004 -0.003 -0.002 -0.001 0 0.001 0.002 0.003 0.004 0.005I had some success in getting the desired output. But i face a problem when i... (15 Replies)
Discussion started by: dinesh.n
15 Replies

4. UNIX for Dummies Questions & Answers

Reading Xml file and print the values into the text file in columnwise?

hi guys, i want help... Reding XML file and print the values into the text file using linux shell script file as per below xml file <sequence> <Filename>aldorzum.doc</Filename> <DivisionCode>US</DivisionCode> <ContentType>Template</ContentType> <ProductCode>VIMZIM</ProductCode> </sequence>... (4 Replies)
Discussion started by: sravanreddy
4 Replies

5. Shell Programming and Scripting

File comparison in UNIX columnwise

Hi all, I want to compare two files with same number of rows and columns with records in same order. Just want to highlight the differences in the column values if any. file A 1,kolkata,19,ab 2,delhi,89,cd 3,bangalore,56,ef file2: 1,kolkata,21,ab 2,mumbai,89,gh 3,bangalore,11,kl... (9 Replies)
Discussion started by: prabhat.diwaker
9 Replies

6. Shell Programming and Scripting

Trim a file columnwise

Hi All, I want to trim each columns leading & trailing (like sql trim function) of a ',' separated file.. I've a file like this.. manab , c gi lucky , home babu , maa I want the output as manab,c gi lucky,home babu,maa A one liner would be a great help. (2 Replies)
Discussion started by: manab86
2 Replies

7. Shell Programming and Scripting

Doubt with rearranging file through awk

Filename1.xml NO 2012-11-16 02:00:27 20121115/pathname/ asia Filename1.rec YES 2012-11-16 01:20:24 20121115/pathname asia FIleName2.xml YES 2012-11-16 01:20:25 20121115/pathaname asia if the file content are... (6 Replies)
Discussion started by: manas_ranjan
6 Replies

8. UNIX for Advanced & Expert Users

Insert records in a file columnwise

Hello everyone!!!!! Need some help on inserting data in a file columnwise. Example: File1: 1|AAA|25|2 5|qqe|20|7 4|wer|31|81 I need to create a second file in which data can be inserted in a columnwise manner i.e. File2: AAA|25|1|2 qqe|20|5|7 wer|31|4|81 The order of columns in... (1 Reply)
Discussion started by: abhijeet1409
1 Replies

9. Shell Programming and Scripting

Insert records in a file columnwise

Hello everyone!!!!! Need some help on inserting data in a file columnwise. Example: File1: 1|AAA|25|2 5|qqe|20|7 4|wer|31|81 I need to create a second file in which data can be inserted in a columnwise manner i.e. File2: AAA|25|1|2 qqe|20|5|7 wer|31|4|81 The order of columns in... (1 Reply)
Discussion started by: abhijeet1409
1 Replies

10. Shell Programming and Scripting

Trying to print data row/columnwise

PRDCNT=12 FILS= f1=1 f2=2 f3=3 f4=4 f5=5 CNT=0 CNT=`expr $PRDCNT - 5` MNT=6 VR=1 while do f$VR="$f$VR,$MNT" echo "$f$VR" MNT=`expr $MNT + 1` CNT=`expr $CNT - 1` VR=`expr $VR + 1` if then (8 Replies)
Discussion started by: swaminathanks
8 Replies
Login or Register to Ask a Question