Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

SED Newb - Range Rage!

Options
  • 08-06-2009 1:20pm
    #1
    Closed Accounts Posts: 8,478 ✭✭✭


    I've been trying to get my head around SED but I think my beginner status is starting to prove too great a hindrence. I have nearly 100 CSS files that I need to modify in such a way that
    label, b, p .text{
    some style stuff
    }
    

    would become
    b ,p .text{
    some style stuff
    }
    
    label {custom style stuff}
    

    label can appear above in the following ways
    label [B],[/B]...
    
    label[B],[/B] ....
    
    [B],[/B] label...
    
    [B],[/B]label...
    

    What I was trying to do was operate the the different flavours of 'label', and then find the next closing tag '}'. I'm testing the finding of 'label' with
    sed 's/,label//g;s/, label//g;;s/label,//g;s/label ,//' test.css
    
    test.css
    
    body{
    
        color: #000000;
        font-family: Verdana, Arial, Helvetica, Sans-Serif;
        font-size: 10px;
        margin: 0px;
        padding: 0px;
            background:white;
            /*background-image: url(images/background.gif);*/
    }
    
    label ,b, p, .text  
    {
        color: #000000;
        font-family: Verdana, Arial, Helvetica, Sans-Serif;
        font-size: 10px;
    }
    
    label,b, p, .text  
    {
        color: #000000;
        font-family: Verdana, Arial, Helvetica, Sans-Serif;
        font-size: 10px;
    }
    
    b, p, label .text  
    {
        color: #000000;
        font-family: Verdana, Arial, Helvetica, Sans-Serif;
        font-size: 10px;
    }
    
    b, p,label .text  
    {
        color: #000000;
        font-family: Verdana, Arial, Helvetica, Sans-Serif;
        font-size: 10px;
    }
    

    If anyone could give me some direction I'd really appreciate it.


Comments

  • Closed Accounts Posts: 8,478 ✭✭✭GoneShootin


    Ok so I got the "label" bit sorted, but finding the next ending curly brace is proving too much for me.

    SED for label removal with commas front and back
    sed 's/\,*[ ]*label[ ]*\,*//g'
    


  • Registered Users Posts: 3,721 ✭✭✭E39MSport


    messy

    sed 's/^label, //g' file.txt | sed '/}/G'; echo "label {custom style stuff}"

    I think perl would be better but I dont use it tat much.


Advertisement