Deleting certain new lines from a file with shell


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Deleting certain new lines from a file with shell
# 8  
Old 02-16-2011
Hi all, thanks for your help!!
I changed the
Code:
>> newfile

to
Code:
>newfile

, and the output its the same. I cant open the text file with gedit, and i cant open it with my software (which is suposed to do some analysis to the data).

But when i use
Code:
cat

, just like vgersh sugested, the data shows like its suposed to be. Here its the output from cat:

Code:
 
>seq_0
GTGAGATTGCTAATGAGCTGCTTTTAGGGGGCGTGTTGTGCTTGCTTTCCAACTTTTCTAGATTGATTCTACGCTGCCTCCAGCAGCCACCCCTCCCATCACCATTCCCATCACCATCCAGTCCCGTTGGCTCCCAGTCACAGTATTACACGTATGCAAATTAAGCCGAAGTTCAATTGCGACCGCAGCAACAACACGATCTTTCTACACTTCTCCTTGCTATGCTTGACATTCACAAGGTCAAAGCTCTTAATATTCTGGCTCGTGGCCCTACACTGTAAGAAATTACTATAGAAATAACGGTACACG
>seq_1
TTATGTCTCGATTCCAGCTAAATTGTCGCCTAAAGACGCCTCCGCCGGCGTTGAGCGCCGAGCAGCATCTGGCACGCATCGAGGTTTTCAATTCGCTGGCCGTGACAGCACCCCAAATCGAGGTGGACCGCCTGCGCTACGATAGGCGGCACAACATGAGCGGTAAGTGGATGCCACCAGCGGTTGGATCTGTGGGCGTGGCAGTGGGAGTGGGAGTACGTGCCAGTCACGGCTGCCGTACCACCCGAAAACCAAGTGCTGTGCCAAAAGCCCAAACATTTCGATTTCCTTCACTAATTACTTGTAAACACTCGTAACACTCGCAAATTAATTGGGGGGTTTCCTTCATGAGGTTTTCGCTTTCATCATATAATTGTATATAAATGTATGCCTTCGATTGAAGTTTGATATT
>seq_2
ACCAAAATAAATCTGGGAACTGAATAATCGAAAATAACTGGATGTGCATCATAAGATCTTCTTTTGAAGACTGACTACAGTTTGCAGCTCAGCGAGCTCGGGCCGGCAACTCAAGCCGGTCAACTCAAGTCAGGCGCCAATTCGCTGCTCCCACTCGCTCAGCTCTCTCAGTCACTCAAAATGGCAACGAGAGCAGAACGGTTCTTTTGCAAAATACTTTATGACCGGAGCAGAAGCAGAATCGGACCTCTGTCGCGGTCGCAGTCGCTGCCAGTGCTGACGGCGCTGTTGCGGCCGACGCTGACGCACATAAATAAAACGCTCTCTTTCGCTCACGAGTTTCTTATAAGACTTTATTTATATACTGCGCTGCCACCGCTGACTGCGCGCCGCCGCCGCCGACTGCGCTGGATTAATAAGGAGTTCTCGCTGGGATTTTCACATGTATATGCTTTGAATTGAATGCTTTATGGGTTTAGTTTGATAGGAGTCGTAAAGAAATCAACATCACACAA
>seq_3
TTCCTGACGAGATCGCTCTCTTTCCACAAATTCGAGTTGGGAAGCACGTGAGTAGAATTCAAAATGTTTTGCTTGCTGTTTTAAATATCACTAGGTTCTCAAACTAATTTCAAAAATAATCAAATTAAGTTCACAGAGCTGGCAAATAAAATGTAATAGCTTGCATGTATGNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNCCATGGAAAATAAAGCCTTTGATATCCAGTTACTGATTCAGCGCCCAATTAATGCATGTTCCAAAAAAGTGTCAAAAAACGTGCACAAATCAAACGAGAGCTGAGGGCCCCGAATTCTATAGTGCTTA

And thats correct, but the problem is the "format" of the file that creates, at the moment i cant open the file except with cat. Any ideas? maybe convert the file?

---------- Post updated at 03:51 PM ---------- Previous update was at 03:39 PM ----------

Maybe its because i need a plain text file and im getting some kind of "rich" text file?
# 9  
Old 02-16-2011
There's a couple of questions you didn't answer:
  • Can you open the file in another editor (like vi)?
  • What is the output of file your_input_file?

And another couple of questions:
  • What OS are you using?
  • What shell are you using?
# 10  
Old 02-16-2011
What is the output of file your_input_file ?
Code:
 
ASCII text, with very long lines, with CRLF line terminators

And the output of file my_output file is:
Code:
 
ASCII text

To the other question, yes, im able to open the file with vi and cat.
Im using ubuntu with bash shell.

Thanks!
# 11  
Old 02-16-2011
Thanks for clearing that up Smilie

I'm with vgersh99, and know little about gedit.

You have the output you wanted (even if you can't read it in gedit). I presume that output served a bigger purpose than gedit.

Read the documentation for the editor. Perhaps there's a setting you could change to allow it to read the file.
# 12  
Old 02-16-2011
My mistake, just double checked the output of "file my_output_file" and it shows:
Code:
$ file dm01new
dm01new: data

Is there a way to convert it to ASCII?

---------- Post updated at 04:55 PM ---------- Previous update was at 04:39 PM ----------

Browsing around found this:
Code:
 
strings old > new

And that solved my problem!!!!! Thanks for your help =D

Last edited by Scott; 02-16-2011 at 04:46 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

deleting few lines from a file dynamically

here is the part of the code var1="replicate-ignore-db" var2="replicate-same-server-id" var3="skip-slave-start" var4="report-host" var5="master-host" var6="master-user" var7="master-password" var8="master-port" #code below deleted paramters as above if exists in my.cnf for i in 1 2 3 4... (4 Replies)
Discussion started by: vivek d r
4 Replies

2. Shell Programming and Scripting

deleting specific lines in a file

Hello, I have a file like: 26-07-2011 sunz02 message1 26-07-2011 sunz02 message2 26-07-2011 sunz02 message3 15-07-2011 sunz02 message1 15-07-2011 sunz02 message2 15-07-2011 sunz02 message3... (5 Replies)
Discussion started by: asanchez
5 Replies

3. Shell Programming and Scripting

Deleting specific lines in a file

Hello, I have a file like this one: 03-07-2011 sunz02 message1 03-07-2011 sunz02 message2 03-07-2011 sunz02 message3 01-07-2011 sunz02 message1 01-07-2011 sunz02 message2 01-07-2011 sunz02 ... (1 Reply)
Discussion started by: asanchez
1 Replies

4. Shell Programming and Scripting

Shell deleting specific lines

Hi, I'am working under unix solaris I have a text file with set of lines, each set of lines (BLOCK) have three fixed lines : Between SECND line and THEND we have N lines, N differ from a block to another sample : i have to make a script wich delete each 3 fixed lines if N=0... (3 Replies)
Discussion started by: salbanito
3 Replies

5. Shell Programming and Scripting

deleting the lines at the end of the file.

I have a text file with two coulmn first column is just used in to show the line number, these line number are not there in the real file. I want to delete the line 16(in this file) here, even tough there is no data inside it . this empty line is causing me a problem by throwing me garbage... (12 Replies)
Discussion started by: shashi792
12 Replies

6. Shell Programming and Scripting

deleting lines from file

We have a server that logs transactions to a file. I want to write a script that will delete the first 50 lines of the file daily without renameing the file or moving the file. (8 Replies)
Discussion started by: daveisme
8 Replies

7. UNIX for Advanced & Expert Users

Deleting lines from a file

How I can delete 100 lines anywhere in a file without opening a file and without renaming the file. (11 Replies)
Discussion started by: Nirgude07
11 Replies

8. UNIX for Dummies Questions & Answers

Deleting whole lines from a file

I have a file with 65 sets of 35 coordinates, and would like to isolate these coordinates so that I can easily copy the coordinates to another file. The problem is, I've got a 9 line header before each set of coordinates (so each set is 44 lines long). There are a zillion threads out there about... (3 Replies)
Discussion started by: red baron
3 Replies

9. Shell Programming and Scripting

Deleting lines in a file

How do I delete all the lines after the line containing text ***DISCLOSURES*** . I want to delete this line too. Thank you (2 Replies)
Discussion started by: reachsamir
2 Replies

10. Shell Programming and Scripting

Deleting last 2 lines from the file.

Hi I have a file & always I need to remove or delete last 2 lines from that file. So in a file if I have 10 lines then it should return me first 8 lines. Can someone help me? (4 Replies)
Discussion started by: videsh77
4 Replies
Login or Register to Ask a Question