How to Delete string without opening a file

Hi Experts,

I have several big size file arround 900 MB. From the file I need to delete some common strings but without opening the file. here is example- in file

<?xml version='1.0' encoding='ISO-8859-1' standalone='no'?>
<LogItems>
<log logid="8423b5ae190810252359350480/1/1/1">

<category>ProcEngineBL.Normal</category>
<operation>DC::sendGetCommand</operation>
<starttime>20081025235935.515410</starttime>
<stoptime>20081025235935.723993</stoptime>
<status>FAILED</status>
</log>
<log logid="8423b5ae190810252359350480/1/1"><category>ProcEngineBL.Normal</category>
<operation>Get</operation>
<target>DC.Subscription</target>
<fullOperation>DC::getCommand</fullOperation>
<starttime>20081025235935.508385</starttime>
<stoptime>20081025235935.724373</stoptime>
<status>FAILED</status>
</log>
<log logid="8423b5ae136366384884759350480/1/1"><category>ProcEngineBL.Normal</category>
<operation>Get</operation>
<target>DC.Subscription</target>
<fullOperation>DC::getCommand</fullOperation>
<starttime>20081025235935.508385</starttime>
<stoptime>20081025235935.724373</stoptime>
<status>FAILED</status>

I want to delete the above Red Colored Strings from the File but without opeining the file. You know its 900MB file. so, its time consuming to open.

Please help.

If you want to modify a file you always have to open something (either using kernel's filesystem implementation or doing it the forensic way by opening a device directly and using the filesystem libs on user-space to control exactly what you're doing).

Anyway, the problem is not opening a file but reading it! And yet, I always have to read the file and then handle strings/patterns to delete something.

Hence,

 sed "/<\/log>/ { N; s/<\/log>\n<log logid=\"8423b5ae136366384884759350480\/1\/1\">//; s/<\/log>\n<log logid=\"8423b5ae190810252359350480\/1\/1\">// }" YOUR-900MB-FILENAME-HERE > new900MBfileWithoutThoseTwoEntries

This might take a while.

Cant we do something like this?
sed -n -e '/<log logid="8423b5ae190810252359350480/1/1">/d' file.txt > file.txt

no, you can't. You'd overwrite you input source while reading it.

Yeah, and furthermore this is a multi-line match.

man sed

.....
       -i[SUFFIX], --in-place[=SUFFIX]

              edit files in place (makes backup if extension supplied)
sed '/<\/log>/{
N
s/<\/log>\n.*\/1\/1">//
}' filename