View Full Version : I Need a Program that can do ...
I have a txt file with lots and lots of lines of text.
I need a program that can sweep through the file, line by line, and delete every line that has a certain string in it.
I can write this in C, but I don't remember how to deal with files. And frankly, I don't want to remember.
Anyone?
Zopperoni
May 28, 2007, 10:18
Open it in Word and do a "Find and Replace" with a blank?
Jon Miller
May 28, 2007, 10:20
use awk
http://www.opengroup.org/onlinepubs/009695399/utilities/awk.html
JM
Solver
May 28, 2007, 10:22
It's been 30 minutes since the post - really, you could've easily written a program to do it by now ;).
I actually started doing that but I have an ancient C compiler that gave me too many weird errors unconnected to the code. Screw it.
JM:
I'd rather write code in a language I know. :)
HTF do I read until EOL (not EOF) in C?
I have achieved victory over the evil compiler. :dance:
Learned a lot about C++ too.
Kuciwalker
May 28, 2007, 11:32
DanS knows regex? WTF? ;)
aneeshm
May 28, 2007, 11:45
Originally posted by Eli
HTF do I read until EOL (not EOF) in C?
The '\n' character indicates the carriage return, as far as I'm aware.
Thanks aneeshm, I already written the program.
I just used getline to avoid the EOL hassle. It's all very simple once you find a page on the internet with a list of all the commands. :)
VetLegion
May 28, 2007, 15:13
If it works, great. If it doesn't, scream. I've done some C programming so maybe I can help.
What VetLegion means is that he's done some butt massages.
It works. The hard part was figuring out what functions I have at my service. The algorithm itself is trivial. I just had to run it a number of times, killing all the variations (capital letters and stuff).
VetLegion
May 28, 2007, 15:25
What VetLegion means is that he's done some butt massages.
Is that how you write code in the Former Swedish Province of Finland?
No. Our programming is usually world class. We don't do butt massages then. In Finland, only gay people and bi-sexuals do that. I don't know how it is in Croatia, but I think we are kind of sticking with the definition. I know! Silly us... so Lutheran. Do what the book says.... follow the rules. I guess you liberal Croats have taken another approach.
I guess you guys go like, "Dobro jutro! Can I butt massage you because it is such a fine day!?".
BlackCat
May 28, 2007, 15:31
If you are running unix/linux, try using egrep -v next time (or get a unix tool package for windows).
VetLegion
May 28, 2007, 16:04
Originally posted by Pekka
I guess you guys go like, "Dobro jutro! Can I butt massage you because it is such a fine day!?".
No, it goes:
"Dobro jutro! Mogu li ti izmasirati guzicu jer je tako lijep dan?"
We don't mix English with Croatian when we speak :shame:
No wait. Doesn't that really mean, "Yes, I packed my bags and never left them unintended" ??
VetLegion
May 28, 2007, 16:07
No. Our programming is usually world class.
I doubt it, I doubt it. I didn't hear of anything good coming from Finland since Linus T., which was like 50 years ago. I think even Estonia has Finland beat in the hi-tech world (Skype, etc...).
Any why is that? Because Finland is finlandized and you don't dare do anything until you ask the Russians :b:
VetLegion
May 28, 2007, 16:09
Originally posted by Pekka
Doesn't that really mean, "Yes, I packed my bags and never left them unintended" ??
Unintended? I bet that sentence makes sense in Finnish and in Russian, but it doesn't in English nor Croatian.
I meant attended... well anyway. I don't mind making few mistakes. At least I'm not the one on the bottom bunk.
VetLegion
May 28, 2007, 16:19
Finland - a nation of Putin's butlers :lol:
You know that won't work. It's just too obvious VL... I'd expect a real effort from you :(
VetLegion
May 28, 2007, 16:41
Is that the phone ringing Pekka? Shouldn't you answer? Maybe the Russian embassy needs a pizza? :cool:
Dude, you just don't know what makes me tick. It's not Russian things, it's not suggestions about sexuality, none of that stuff really bothers me.
Things that tick me off have never been discovered here... :)
VetLegion
May 28, 2007, 16:53
I think you overestimate yourself. One's character, fears and phobias can be pretty well deduced from his posts.
Especially if he keeps us up to date about them with dozens of threads, like you do :rolleyes: ;)
I think you need a hug. Lately, you've been trying to get me going on, making thread about Foucault and all this stuff. It doesn't bother me VL, in my eyes, you're just a lost puppy looking for love.
VetLegion
May 28, 2007, 17:01
Foucault :q:
New Age in general and New Ageist Pekka in particular :q:
Deepak Chopra :b:
Puppies looking for love :b: :q: (I'm undecided)
MightyTiny
May 28, 2007, 18:15
Originally posted by VetLegion
Deepak Chopra :b:
:shame:
Pseudoscientific feel-good nonsense. :doitnow!:
Oh, and to stay on topic... EditPad lite is a nifty little free program that's got search and replace features. ( http://www.editpadpro.com/editpadlite.html )
Ari Rahikkala
May 29, 2007, 02:21
Originally posted by BlackCat
If you are running unix/linux, try using egrep -v next time (or get a unix tool package for windows).
QFT. I have no idea why decent people were trying to get Eli to do things in unnecessarily complicated ways. This problem just screams grep, everything else in this thread is inappropriate.
Solver
May 29, 2007, 09:15
Because people who don't run a UNIX-like system deserve to be doing easy things the hard way, such as writing C++ code instead of using grep :p
VetLegion
May 29, 2007, 18:02
There's grep for Windows too ;)
BlackCat
May 29, 2007, 18:09
:hmmm: he could be a mac, but well, there are unix tools for that too.
Solver
May 29, 2007, 18:33
Originally posted by VetLegion
There's grep for Windows too ;)
That's like sticking Hellfire missiles on a Fokker Spin :p
BlackCat
May 29, 2007, 18:37
Originally posted by Solver
That's like sticking Hellfire missiles on a Fokker Spin :p
Wouldn't that make that Fokker a quite capabable unit ;)
Solver
May 29, 2007, 18:41
It'd be ugly and not really work too well together ;)
BlackCat
May 29, 2007, 18:55
Well, this is a ugly MF'er that you wouldn't think could fly, but it does and is pretty good (though, don't think there are any MS SW inside)
Solver
May 29, 2007, 19:27
Wow, that one is uglier than Windows :D
VetLegion
May 30, 2007, 17:09
A-10 Thunderbolt, is it?
Kuciwalker
May 30, 2007, 17:10
Originally posted by Solver
Wow, that one is uglier than Windows :D
Dude, it looks awesome.
Kuciwalker
May 30, 2007, 17:11
Originally posted by VetLegion
A-10 Thunderbolt, is it?
Yep.
KrazyHorse
May 30, 2007, 17:53
Originally posted by Ari Rahikkala
QFT. I have no idea why decent people were trying to get Eli to do things in unnecessarily complicated ways
Because it's funny.
Sirotnikov
May 30, 2007, 18:36
Originally posted by Eli
I have a txt file with lots and lots of lines of text.
I need a program that can sweep through the file, line by line, and delete every line that has a certain string in it.
So how did your attempt to delete traces of your porn addiction from the browser history files workout? :cool:
vBulletin® v3.8.2, Copyright ©2000-2010, Jelsoft Enterprises Ltd.