 |
 |
simple command line question?
|
 |
|
 |
|
Senior User
Join Date: Sep 2000
Location: Shallow Alto, CA
Status:
Offline
|
|
Hi,
I would like to scan a large text file (50MB) and remove all lines conating a specific string, lets say "aaaaa". I don't really care about saving those lines, just getting rid of them from the original file.
I tried using the little knowledge of grep that I have, but all I ended up with was a file containing the lines I didn't want.
Any suggestions?
TIA
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Dec 2001
Location: Atlanta, GA, USA
Status:
Offline
|
|
This should work:
Code:
grep -v "pattern" file > output.txt
That will find all lines not containing pattern and will redirect them into the file output.txt
|
|
Mac Pro 2x 2.66 GHz Dual core, Apple TV 160GB, two Windows XP PCs
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Sep 2000
Location: Shallow Alto, CA
Status:
Offline
|
|
I found a perl tutorial that gave me some hints and ended up with
perl -pi.bak -e 's/.*G{5,}.*$//; s/.*C{5,}.*$//; s/.*A{5,}.*$//; s/.*T{5,}.*$//; s/^\s*$//' filename
I'm sure there is a more elegant way to do it, but it worked in removing all lines with 5 or more G A T or C.
thanks
|
|
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Nov 2001
Location: State of Denial
Status:
Offline
|
|
|
|
|
[Wevah setPostCount:[Wevah postCount] + 1];
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Nov 2001
Location: State of Denial
Status:
Offline
|
|
Why not just:
perl -pi.bak -e 's/^.*[GCAT]{5,}.*$//;' filename
?
|
|
[Wevah setPostCount:[Wevah postCount] + 1];
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Sep 2000
Location: Shallow Alto, CA
Status:
Offline
|
|
Yep DNA.
I spent the last hour trying to get that exact syntax to work, but gave up and just strung them all together one after another.
My knowledge of regular expressions is only as good as the tutorial I'm reading at the time!
Thanks for showing me the elegant way of getting it done...now if I could just get some Linux code to compile I'd be home free.
|
|
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Nov 2001
Location: State of Denial
Status:
Offline
|
|
Word; glad I could be of some help!
|
|
[Wevah setPostCount:[Wevah postCount] + 1];
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|