Modifying rows


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Modifying rows
# 1  
Old 05-26-2009
Modifying rows

Hi,

I have a file that looks something like this (2 columns 4 rows):

eeeeeeeeeeeeeeeeeeeeeeeeeeeee -45
rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr -24
ttttttttttttttttttttttttttttttttttttttttttt -29
uuuuuuuuuuuuuuuuuuuuuuuuuuu -23

How do I get it to look like this:

-45
eeeeeeeeeeeeeeeeeeeeeeeeeeeee
-24
rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
-29
ttttttttttttttttttttttttttttttttttttttttttt
-23
uuuuuuuuuuuuuuuuuuuuuuuuuuu

Thanks

Phil
# 2  
Old 05-26-2009
try:
Code:
 sed  's/\(.*\) \(.*\)/\2 \1/' yourfile  |tr ' ' '\n'

# 3  
Old 05-26-2009
Code:
 nawk '{print $2, $1}' OFS='\n' myFile

# 4  
Old 05-27-2009
Quote:
Originally Posted by edgarvm
try:
Code:
 sed  's/\(.*\) \(.*\)/\2 \1/' yourfile  |tr ' ' '\n'

small change to your solution without using 'tr'
Code:
sed  's/\(.*\) \(.*\)/\2\
\1/' a

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Moving or copying first rows and last rows into another file

Hi I would like to move the first 1000 rows of my file into an output file and then move the last 1000 rows into another output file. Any help would be great Thanks (6 Replies)
Discussion started by: kylle345
6 Replies

2. Shell Programming and Scripting

Merging rows using two common rows.

Hi.. My requirement is simple but unable to get that.. File 1 : 3 415 A G 4 421 G . 39 421 G A 2 421 G A,C 41 427 A . 4 427 A C 42 436 G . 3 436 G C 43 445 C . 2 445 C T 41 447 A . Output (4 Replies)
Discussion started by: empyrean
4 Replies

3. UNIX for Dummies Questions & Answers

merging rows into new file based on rows and first column

I have 2 files, file01= 7 columns, row unknown (but few) file02= 7 columns, row unknown (but many) now I want to create an output with the first field that is shared in both of them and then subtract the results from the rest of the fields and print there e.g. file 01 James|0|50|25|10|50|30... (1 Reply)
Discussion started by: A-V
1 Replies

4. Shell Programming and Scripting

Need some help modifying script

I have a script that currently runs fine and I need to add or || (or) condition to the if statement and I'm not sure the exact syntax as it relates to the use of brackets. my current script starts like this: errLog="/usr/local/website-logs/error.log" apacheRestart="service httpd restart"... (3 Replies)
Discussion started by: jjj0923
3 Replies

5. Shell Programming and Scripting

Modifying the cd command

Hello everyone, I am currently doing a utility that acts like a cd command but keeps track of your change of directories. What I plan to do is just to modify the cd source code, is that even possible? Can someone please help me with this? I also need to incorporate the command with the... (3 Replies)
Discussion started by: iennetastic
3 Replies

6. Shell Programming and Scripting

Split single rows to multiple rows ..

Hi pls help me out to short out this problem rm PAB113_011.out rm: PAB113_011.out: override protection 644 (yes/no)? n If i give y it remove the file. But i added the rm command as a part of ksh file and i tried to remove the file. Its not removing and the the file prompting as... (7 Replies)
Discussion started by: sri_aue
7 Replies

7. Shell Programming and Scripting

Remove 1st two rows and last 2 rows

Hi All, I need to remove 1st 2 line from head and last 2 line from last. I thought it would be possible by using the Head and tail command. But after i am using it is not possible by it. Example:Input file 1 2 3 4 5 Example: Output file 3 But my head and tail command are not... (12 Replies)
Discussion started by: kam786sim
12 Replies

8. Shell Programming and Scripting

Help with modifying files

Hello everyone, I have some data files, with mixed header formats. the sample for the same is: >ABCD76567.x1 AGTCGATCGTAGTCGTAGCTGT >ABCD76567.y1 AGTCGATCGTAGTCGTAGCTGT >ABCD76568.x1 pair_info:898989 AGTCGATCGTAGTCGTAGCTGT >ABCD76568.y1 pair_info:893489 AGTCGATCGTAGTCGTAGCTGT... (2 Replies)
Discussion started by: ad23
2 Replies

9. Shell Programming and Scripting

Deleting specific rows in large files having rows greater than 100000

Hi Guys, I need help in modifying a large text file containing more than 1-2 lakh rows of data using unix commands. I am quite new to the unix language the text file contains data in a pipe delimited format sdfsdfs sdfsdfsd START_ROW sdfsd|sdfsdfsd|sdfsdfasdf|sdfsadf|sdfasdf... (9 Replies)
Discussion started by: manish2009
9 Replies

10. UNIX for Dummies Questions & Answers

Converting rows into multiple-rows

Hi every one; I have a file with 22 rows and 13 columns which includes floating numbers. I want to parse the file so that every five columns in the row would be a new record (row). For example, the first line in the old file should be converted into three lines with first two lines contain 5... (6 Replies)
Discussion started by: PHL
6 Replies
Login or Register to Ask a Question