Help with SED in Ubuntu



  • I want to SED a file. That file contains many lines. There is a two-possibilities string I want to replace:

    scenario 1:
    ///

    scenario 2:
    //anything/

    In both cases I want to replace what occurs between // and /.

    What I’m trying:

    VAR=<something>
    sed -i "s;//([^/]+)/;//$VAR/; " /path/file

    This only works for scenario 2. I already have a second sed line in place to brute force replace /// whenever it occurs, but I would love to have it in a single command if possible.


Log in to reply
 

459
Online

38969
Users

10710
Topics

101656
Posts

Looks like your connection to FOG Project was lost, please wait while we try to reconnect.