I want to replace values in file.

Replace :

  • values #startdate# with - '01-Jan-2015'
  • values #code# with - 'SA','CA'
  • 1
    what have you tried so far ? this seems pretty easy, try searchinf for sed tag. – Archemar May 29 '16 at 12:51

If you want to replace in a file named "filename" do

sed -i 's/#startdate#/01-Jan-2015/g' filename

the -i option will overwrite your file on linux


sed -i 's/#CODE#/"'CA','03'"/g' filename
  • Thanks a lot for you reply. I have the SQL syntax as '#StartEffStartDate#' and '#EndEffStartDate#' I need this to be '01-Jan-2015' and '21-Jan-2015' after replace. I can replace StartEffStartDate with 01-Jan-2015. I need help to replace including #StartEffStartDate# – Amirthaprakash Chidambaram May 29 '16 at 13:46
  • sed -i 's/#CODE#/'CA','03'/g' Test.sql This gives ouput as "in (X,03);" I want the output to be "in ('X','03');" – Amirthaprakash Chidambaram May 29 '16 at 14:06
  • I updated my answer... But I'm not sure I understood your last comment – PinkFloyd May 30 '16 at 5:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.