Inserting line break where ';' is


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Inserting line break where ';' is
# 1  
Old 12-16-2009
Power Inserting line break where ';' is

I did some past data manipulations using awk so I could join lines in order to use grep. Now that I have newly searched data I need to insert a new line break to use further statistical packages. I have a data base that looks something like this:

Code:
>bat_aaj05a03;AGAGTTTGATCCTGGCTCAGGATGAACCCTGGCGGCGTGCCTAAT
>bat_aaj05a06;GTTTGACGGTACCATACCAGAAAGGGACGGCTAAATACGTGCCAG
>bat_aaj05a05;AGAGTTTGATCCTGGCTCAGGATGAACGCTGGCGGCGTGCCTAAT

And I want it to look like this

Code:
>bat_aaj05a03
AGAGTTTGATCCTGGCTCAGGATGAACCCTGGCGGCGTGCCTAAT
>bat_aaj05a06
GTTTGACGGTACCATACCAGAAAGGGACGGCTAAATACGTGCCAG
>bat_aaj05a05
AGAGTTTGATCCTGGCTCAGGATGAACGCTGGCGGCGTGCCTAAT

I tried opening it in excel and delimiting it, but that inserted a tab after my header, which doesn't work in the statistical software I'm using.

Thanks so much for all your help!!

Last edited by Scott; 12-17-2009 at 06:03 AM.. Reason: Please use code tags
# 2  
Old 12-16-2009
Code:
gawk -F";" -vOFS="\n" '{$1=$1}{print}' file

# 3  
Old 12-17-2009
Code:
sed 's/;/\n/' urfile

awk 'gsub(/;/,"\n")' urfile

# 4  
Old 02-24-2010
Bug

Hi,

tr command also used for replace the ; into newline.

tr ";" "\n" < file


output:
----------
bat_aaj05a03
AGAGTTTGATCCTGGCTCAGGATGAACCCTGGCGGCGTGCCTAAT
bat_aaj05a06
GTTTGACGGTACCATACCAGAAAGGGACGGCTAAATACGTGCCAG
bat_aaj05a05
AGAGTTTGATCCTGGCTCAGGATGAACGCTGGCGGCGTGCCTAAT
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to break the line to the one above?

Hello everyone! I'm trying to make the below file1 look like file2, can anyone help? Basically I just hit backspace on every line that starts with a number. Thanks! file1: THIS#IS-IT1 4 THIS#IS-IT2 3 THIS#IS-IT3 2 THIS#IS-IT4 1 Result > file2: (4 Replies)
Discussion started by: demmel
4 Replies

2. Shell Programming and Scripting

Commenting a specific line and inserting a new line after commented line.

Hello All, I have following file contents cat file #line=aaaaaa #line=bbbbbb #line=cccccc #line=dddddd line=eeeeee #comment=11111 #comment=22222 #comment=33333 #comment=44444 comment=55555 Testing script Good Luck! I would like to comment line line=eeeeee and insert a new line... (19 Replies)
Discussion started by: manishdivs
19 Replies

3. Shell Programming and Scripting

Line Break problem

Hi All, Please can you advise/help on the below issue i did a bcp out of a table, it is having problem of line break such that one line is getting broken in two lines for many records. eg Correct format Line 1: - 000f00000bfe2c2c 000218310300000000GBP GBP 734654 10970.35 ... (3 Replies)
Discussion started by: mad_man12
3 Replies

4. UNIX for Dummies Questions & Answers

VI Line Break?

So I'm in a Unix class and our assignment was to go into VI and write a script to make this file tree. At the end of it, I'd like it to echo "This is the file tree you've created" then a line break, then . But I'm not sure as to who to do it. Is there a way for when I run it (./filesystem), the... (4 Replies)
Discussion started by: bbowers
4 Replies

5. Shell Programming and Scripting

Add line break for each line in a file

I cannot seem to get this to work.. I have a file which has about 100 lines, and there is no end of line (line break \n) at the end of each line, and this is causing problem when i paste them into an application. the file looks like this this is a test that is a test balblblablblhblbha... (1 Reply)
Discussion started by: fedora
1 Replies

6. Shell Programming and Scripting

BASH: Break line, read, break again, read again...

...when the lines use both a colon and commas to separate the parts you want read as information. The first version of this script used cut and other non-Bash-builtins, frequently, which made it nice and zippy with little more than average processor load in GNOME Terminal but, predictably, slow... (2 Replies)
Discussion started by: SilversleevesX
2 Replies

7. Shell Programming and Scripting

Inserting a line in a file after every alternate line

Friends , I have a large file and i need to insert a line after every line.I am actually unaware how to do it.Any help appreciated. My File control station *ATM* , qread $OSS.Jul13A.FI01 interval 1 intcount 1 control station *ATM* , qread $OSS.Jul13A.FI02 interval 1 intcount... (4 Replies)
Discussion started by: appu2176
4 Replies

8. UNIX for Advanced & Expert Users

Inserting a line before the line which matches the patter

Hi Is there any command where we can insert a line "2|||" before every line starting with "3|" my input is as follows 1|ETG|12345 3|79.58|||GBP|| 1|ETG|12345 3|79.58|||GBP|| 1|ETG|12345 2|EN_GB||Electrogalvanize 0.5 m2 ( Renault ) 1|ETG|12345 3|88.51|||GBP|| desired output... (10 Replies)
Discussion started by: laxmi131
10 Replies

9. Shell Programming and Scripting

TO break a line

hi All, Have a doubt in ksh..Am not familiar with arrays but i have tried out a script.. plzzzzz correct me with the script My i/p File is: (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP) (Host = 192.168.2.2) (Port = 1525) ) ) (CONNECT_DATA = (SID = TESTDB1) ) ) ... (7 Replies)
Discussion started by: aajan
7 Replies

10. Shell Programming and Scripting

Remove Line Break

Dear all, Please advise what approach can remove all line break from a text file? e.g. Source file: A B C Target file: A, B, C Thanks, Rock (5 Replies)
Discussion started by: Rock
5 Replies
Login or Register to Ask a Question