Announcement

Collapse
No announcement yet.

using sed to parse html?

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • using sed to parse html?

    I have got the biggest headache!

    I hope I am posting this to the right forum... I am trying to parse an html file using sed in a bash script. My problem is that I need to strip everything up to a particular tag, but the "everything" in this case includes tabs, spaces, newlines and linebreaks.

    The html that I am working on is:
    Code:
     
        <div id="filters">
            <input type="hidden" name="filter-search-previous" value="">
            <input type="text" class="form-control" name="filter-search" placeholder="Search..." value="">
    
            <select class="form-control" name="filter-sort">
                <option >Newest products first</option>
                <option >Sort by expiry ascending</option>
                <option >Sort by expiry descending</option>
                <option >Sort by price (lowest first)</option>
                <option >Sort by price (highest first)</option>
            </select>
     
     
            <button type="button" class="btn btn-warning" style="top: -1px; position: relative; margin-left: 10px;" onclick="refresh_products(0)">Refresh / Search</button>
     
        </div>
        
        <div id="box-container-inner" style="position: relative">
    
            <div class="box" id="product_1208750">
            <div class="img-container">
    Now, what I want to do is to strip out everything up to, and including [ <div id="box-container-inner" style="position: relative"> ]. I have tried the following commands:

    Code:
    sed -i 's/.*<div id="box-container-inner" style="position: relative">//' output.txt
    
    sed -i 's/[\s\S]*<div id="box-container-inner" style="position: relative">//' output.txt
    The first one just deletes that one line, and the second one doesn't do anything. Can someone help me with this? Either that or send me a bottle of aspirin! Thanks
Working...
X

Fatal error: Uncaught exception 'Exception' with message 'MySQL server has gone away' in /data/built2go/hf_home/webm/public_html/htmlforums/vb/core/vb/db/query/update.php:120 Stack trace: #0 /data/built2go/hf_home/webm/public_html/htmlforums/vb/core/vb/db/query/update.php(101): vB_dB_Query_Update->doUpdates() #1 /data/built2go/hf_home/webm/public_html/htmlforums/vb/core/vb/db/assertor.php(283): vB_dB_Query_Update->execSQL() #2 /data/built2go/hf_home/webm/public_html/htmlforums/vb/core/vb/db/assertor.php(518): vB_dB_Assertor->assertQuery('session', Array) #3 /data/built2go/hf_home/webm/public_html/htmlforums/vb/core/vb/session.php(520): vB_dB_Assertor->update('session', Array, Array) #4 /data/built2go/hf_home/webm/public_html/htmlforums/vb/core/vb/library/user.php(911): vB_Session->save() #5 /data/built2go/hf_home/webm/public_html/htmlforums/vb/core/vb/mail.php(437): vB_Library_User->updateEmailFloodTime() #6 /data/built2go/hf_home/webm/public_html/htmlforums/vb/core/vb/mail.php(131): vB_Mail->send() #7 /data/built2go/hf_h in /data/built2go/hf_home/webm/public_html/htmlforums/vb/core/vb/db/query/update.php on line 120