Saving file edited whith sed


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Saving file edited whith sed
# 1  
Old 06-26-2010
Data Saving file edited whith sed

HI!
I have a file that looks like this:

Code:
>ANKRD30_2kb
AAGTAACCAATGCAGGAAACCGAGAGGAGAGGTTTGGAAGGTGGTTTAGTGAGGTAATCCATCTTTTCT
AGTGATAAACTGGCACCCAGTCAATTTATTCATCAGAAGGGAATACATCAGCCTGGCGTGGTGGCTCGC
CCCCGACCCTGTCAGCGTCACCAGCAGCGCGGATCCATGGGCCAGAAGCCTCTAGGGCGCCTAAGTCAG
Number of residues in the repeat = 3
AAG
[ 1 to 3 ]
[ 38 to 40 ]
[ 106 to 108 ]
----------------------------------------------------------------------
Number of residues in the repeat = 3
AGA
[ 23 to 25 ]
----------------------------------------------------------------------
Number of residues in the repeat = 3
AGC
[ 119 to 121 ]
[ 152 to 154 ]
[ 161 to 163 ]
----------------------------------------------------------------------
Number of residues in the repeat = 3
>C3orf24_2kb
TTGTGGTGTGTGTTCTATAGTTTGTAAAATGCAAGGGCAATTCTGGGTGTACAAGGGAAGGCCAAGTAG
GCCATTAGTTACTTCCTCCCACAAATACTGCACACTGCCAGACATGGCAATAGCCAGGTACTGGGAATA
CAGACATCAGCTGGGTAGACTCCTCCCTTCCCTCAGCCATCCAGGGTCATTATTTTAAGTGATGATTAC
Number of residues in the repeat = 3
AAA
[ 26 to 28 ]
[ 27 to 29 ]
[ 92 to 94 ]
----------------------------------------------------------------------
Number of residues in the repeat = 3
AAG
[ 33 to 35 ]
[ 53 to 55 ]
----------------------------------------------------------------------
Number of residues in the repeat = 3

All I want to get from this file is:

Code:
>ANKRD30_2kb
AAG
AGA
AGC
>C3orf24_2kb
AAA
AAG

I've tried to use this command:
Code:
sed '/\[/,/^N/d' file|grep -v "^N"|sed '/^.\{50\}/d'

If I look with it using the head command it seems to work, but when I try to save it into a new file (>newfile) all I get is an empty file!!!. What am I doing wrong???Smilie
Thanks

Last edited by Scott; 06-27-2010 at 06:22 AM.. Reason: Code tags, please...
# 2  
Old 06-26-2010
Code:
egrep '>|^[A-Z][A-Z][A-Z]$' infile

This User Gave Thanks to pseudocoder For This Post:
# 3  
Old 06-26-2010
Quote:
Originally Posted by pseudocoder
Code:
egrep '>|^[A-Z][A-Z][A-Z]$' infile

That's even much more elegant. ThanksSmilie
# 4  
Old 06-26-2010
pseudocoder - doesn't alternation usually require '(pattern1|pattern2)' - the surrounding parentheses? I've never tried it that way....
# 5  
Old 06-26-2010
Code:
egrep '^>|^[A-Z]{3}$' infile

Code:
egrep '^(>|[A-Z]{3}$)' infile

This User Gave Thanks to Scrutinizer For This Post:
# 6  
Old 06-26-2010
Code:
egrep '>|^[A,G,C]*$' infile

This User Gave Thanks to EAGL€ For This Post:
# 7  
Old 06-26-2010
Hi Eagl€, you probably mean:
Code:
egrep '>|^[AGC]*$' infile

But I do not think that works here, since then you filtering on the fact that there happens to be no T present on the lines with 3 characters, otherwise it would match lines with more than 3 of those characters as well.
This User Gave Thanks to Scrutinizer For This Post:
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed command is saving output as blank file

Hi, I am working on a script where I am adding adding colors to few of the info in the output. Now , after that is done , I see colour codes in log files which I don't want to see.:mad::mad::mad::mad: So , I tried using sed command in script as below which gives me o/p (new.log) as blank file... (7 Replies)
Discussion started by: Dream4649
7 Replies

2. Shell Programming and Scripting

sed - Print Edited Line Along With Original Line

Hi, I have an input file like this line1 line2 line3 hello unix how are you This is what I am expecting my output to be line1 line2 #line3 hello unix how are you line3 hello (3 Replies)
Discussion started by: jacobs.smith
3 Replies

3. UNIX and Linux Applications

Notepad++ hang when open file edited in other text editor

Hi, I would like to ask about the notepad++ text editor application, Although there are alternative and more great text editor in linux (gedit, geany, jedit) im still using the notepad++ sometimes cause for some of my own reason one of those is the minimalist text(what i mean is notepad++ has a... (2 Replies)
Discussion started by: jao_madn
2 Replies

4. Shell Programming and Scripting

issue while copying file dynamically whith in loop?

I need to copy the log file dynamically and that should run in loop , which means it should pick what ever the latest file is updated in that directory. I am able to display the list and copy to directly but i have no idea on how to pick the dynamically updated files. when i use this code, i... (1 Reply)
Discussion started by: johninweb
1 Replies

5. Shell Programming and Scripting

How to read a file name that was recently edited when listed using ls command?

I was trying to write a script that will process recently creatd file. From below, the script should process input_20111230.dat file. sam:/top/work/data/input: ls -ltr input_*.dat -rw-rw-rw- 1 work edprod 455668 Dec 24 09:16 input_20111224.dat -rw-r--r-- 1 work edprod ... (7 Replies)
Discussion started by: siteregsam
7 Replies

6. UNIX for Advanced & Expert Users

Who edited my text file?

I was editing my text file in gvim & I was getting message that its changed & to load again. I work in a workplace environment with everyone having there username.. How can I know that who edited my file? (4 Replies)
Discussion started by: krishanu
4 Replies

7. Solaris

/etc/profile file edited. No command working

I have X4500 and I created a user. I wanted to give him root privileges and for editing the sudoers files I typed visudo sudoers. But it said visudo command not found. After googling I found that we need to set path in etc/profile. I edited that and put the following command ... (3 Replies)
Discussion started by: bharu_sri
3 Replies

8. UNIX for Dummies Questions & Answers

Saving changes when using the sed command

Hi Guys, Working on a script in the Vi editor that requires the fifth column of a particular line changed. e.g. Name:Address:email:A where "A" needs to be changed to what the variable $access holds ($access currently has the words admin access in it) when I use this command : `sed... (3 Replies)
Discussion started by: rc1138
3 Replies

9. UNIX for Dummies Questions & Answers

Edited Path in Profile File

Definitely a unix dummy. I edited the paths in the /etc/profile file - following the instructions on an install package. Now can't use vi, cat pg ls or any other unix commands. Guess I'm in big trouble. Path reads MANPATH=/opt/hpnp/man PATH=/opt/hpnpl/bin LD_LIBRARY_PATH=/opt/hpnp/lib ... (4 Replies)
Discussion started by: thewetch
4 Replies
Login or Register to Ask a Question