• Recent
    • Unsolved
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    Help with SED in Ubuntu

    Scheduled Pinned Locked Moved
    Linux Problems
    1
    1
    734
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • sudburrS
      sudburr
      last edited by

      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.

      [ Standing in between extinction in the cold and explosive radiating growth ]

      1 Reply Last reply Reply Quote 0
      • 1 / 1
      • First post
        Last post

      198

      Online

      12.0k

      Users

      17.3k

      Topics

      155.2k

      Posts
      Copyright © 2012-2024 FOG Project