Sed replace

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kaarthikeyapreyan
    New Member
    • Apr 2007
    • 106

    Sed replace

    I run this script in the bash environment GNU bash, version 3.00.15(1)-release (x86_64-redhat-linux-gnu) and sed GNU sed version 4.1.2, which has this line
    Code:
    sed -i 's/$pattern/$desired/g' $file
    this does the desired replace in the command line but not when run in a script.
    what possibly could be the reason.?
  • kaarthikeyapreyan
    New Member
    • Apr 2007
    • 106

    #2
    The other option that i tried was
    Code:
     cat $file | sed -e 's/$pattern/$desired/g' >$file
    but this actually resulted in the desired file being empty.?

    Comment

    • ashitpro
      Recognized Expert Contributor
      • Aug 2007
      • 542

      #3
      Could you please modify the script and print the $file just before the sed command?

      Just check out if it is getting initialized to a desired file name.
      Else, post the error or script.

      Comment

      Working...