Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

SED Newb - Range Rage!

  • 08-06-2009 01: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, Registered Users 2 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