Results 1 to 3 of 3
  1. #1
    Join Date
    May 2005
    Location
    South Africa
    Posts
    1,365
    Provided Answers: 1

    Unanswered: How do I change string x*y to a*b

    How do I change string x*y to a*b
    Where * can be any number of characters
    e.g.
    # cat f1
    1/2/2004
    15/2/2004
    1/11/2004
    15/11/2004
    1/2/2005
    15/2/2005
    1/11/2005
    15/11/2005

    change "15/<any chars>/2005" to "20/<the any chars>/2006" resulting in
    1/2/2004
    15/2/2004
    1/11/2004
    15/11/2004
    1/2/2005
    20/2/2006
    1/11/2005
    20/11/2006

    The closest I get is:
    # cat f1 | sed 's!15/.*/2005!20/&/2006!'
    1/2/2004
    15/2/2004
    1/11/2004
    15/11/2004
    1/2/2005
    20/15/2/2005/2006
    1/11/2005
    20/15/11/2005/2006

  2. #2
    Join Date
    Apr 2004
    Location
    Boston, MA
    Posts
    325
    Code:
    sed 's#^\(15\)\(/.*/\)\(2005\)#20\22006#' f1
    vlad
    +-----------------------+
    | #include <disclaimer.h> |
    +-----------------------+

  3. #3
    Join Date
    May 2005
    Location
    South Africa
    Posts
    1,365
    Provided Answers: 1
    Thank you

Posting Permissions

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