Find the answer to your Linux question:
Results 1 to 2 of 2
I have to replace longer strings with shorter strings, ex. replacing abcdefg, defgh with xyz How can I replace strings while retaining/preserving the number of spaces after the sting? Because ...
  1. #1
    Just Joined!
    Join Date
    Sep 2007
    Posts
    1

    Replacing strings

    I have to replace longer strings with shorter strings,
    ex. replacing abcdefg, defgh with xyz

    How can I replace strings while retaining/preserving the number of spaces
    after the sting?
    Because I need to preserve the formating between columns.

    ex. abcdefg 123 -> xyz ---123 (here - denotes spaces to preserve)
    not abcdefg 123 -> xyz 123

    I have tried using sed 's/'"$old_string"'/'"$new_string"'/g'
    but the output is grabbed.

    TIA,
    Mongster

  2. #2
    Just Joined!
    Join Date
    Jul 2007
    Posts
    41
    Does this work?

    Code:
    sed 's/abcdefg/xyz    /g'
    What's the output you're getting?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...