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.


 

320
Online

41.6k
Users

12.1k
Topics

114.4k
Posts