Home Download Buy Blog Forum Support

delete entire line if it contains certain string

delete entire line if it contains certain string

Postby heaversm on Thu Jan 10, 2013 12:31 pm

Hi - I want to do a "find in files" operation to go through a list of hundreds of .OBJ files. to delete all of their faces (leaving only the vertices). Faces in an obj file look like this:
f 20824/20824 20668/20668 20667/20667
and vertices like this:
v 0.211181 0.436763 1.052000

Each obj file has about 100,000 lines of these coordinates. Is there an operation in sublime text to say:

"If line starts with f, delete line, else do nothing"? How could I go about deleting all faces in the obj file in sublime text?
heaversm
 
Posts: 1
Joined: Thu Jan 10, 2013 12:28 pm

Re: delete entire line if it contains certain string

Postby svenax on Thu Jan 10, 2013 2:41 pm

Turn on regular expression in search and replace.
Search for ^f\s.*\n
Replace with nothing.

Not sure how Sublime Text will handle the hundreds of file with millions of lines though.
svenax
 
Posts: 151
Joined: Tue Dec 20, 2011 12:47 pm

Re: delete entire line if it contains certain string

Postby pete340 on Thu Jan 10, 2013 3:32 pm

svenax wrote:Turn on regular expression in search and replace.
Search for ^f\s.*\n
Replace with nothing.

Not sure how Sublime Text will handle the hundreds of file with millions of lines though.


Indeed. This sounds like a job for sed.
pete340
 
Posts: 72
Joined: Mon Oct 10, 2011 9:45 pm

Re: delete entire line if it contains certain string

Postby adzenith on Thu Jan 10, 2013 11:34 pm

I think the replace may go much faster if you first switch the syntax to plain text - I seem to recall Sublime reparses the syntax coloring between replaces or something? I don't remember if that's actually true, but feel free to give it a shot. :)
adzenith
 
Posts: 1215
Joined: Mon Oct 19, 2009 9:12 pm


Return to Technical Support

Who is online

Users browsing this forum: maara and 12 guests