ML
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Using SED to replace a line with spaces

    IT Discussion
    cli sed editing
    3
    7
    879
    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.
    • DustinB3403D
      DustinB3403
      last edited by

      I'm trying to replace a line in a file using sed.

      so sed -i 's~Your sentence that needs to be replaced~New sentence goes here~g' /file/path/file

      Should work, right? It doesn't result in an error when running my command, but the file doesn't get changed.

      Looking for guidance.

      1 Reply Last reply Reply Quote 0
      • DustinB3403D
        DustinB3403
        last edited by

        Paging @travisdh1 @scottalanmiller @JaredBusch

        One of you three should know how to do this.

        1 Reply Last reply Reply Quote 0
        • B
          bnrstnr
          last edited by

          That looks good to me and works fine here.

          Only thing that comes to mind is the file permissions?

          DustinB3403D 1 Reply Last reply Reply Quote 0
          • DustinB3403D
            DustinB3403 @bnrstnr
            last edited by

            @bnrstnr Okay, will try it again. And I'm running this as root, so not sure.

            1 Reply Last reply Reply Quote 0
            • JaredBuschJ
              JaredBusch
              last edited by

              I typically use / instead of ~ for the delimiter, looks right.

              DustinB3403D 1 Reply Last reply Reply Quote 0
              • DustinB3403D
                DustinB3403 @JaredBusch
                last edited by

                @JaredBusch said in Using SED to replace a line with spaces:

                I typically use / instead of ~ for the delimiter, looks right.

                Have to use ~ because I'm adding a URL in the part that's being replaced.

                Also that did work, not sure why it wasn't showing the change first time.

                Thanks for the sanity check.

                JaredBuschJ 1 Reply Last reply Reply Quote 1
                • JaredBuschJ
                  JaredBusch @DustinB3403
                  last edited by JaredBusch

                  @DustinB3403 said in Using SED to replace a line with spaces:

                  @JaredBusch said in Using SED to replace a line with spaces:

                  I typically use / instead of ~ for the delimiter, looks right.

                  Have to use ~ because I'm adding a URL in the part that's being replaced.

                  Also that did work, not sure why it wasn't showing the change first time.

                  Thanks for the sanity check.

                  wait...... I skimmed. I admit..

                  You have to escape spaces or wrap it in quotes.

                  Oh it worked.. then all good. Ignore me..

                  I'm busy unpurging email.

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