Sed not working inside bash script

Posted by Isabelle on Stack Overflow See other posts from Stack Overflow or by Isabelle
Published on 2010-06-10T15:06:11Z Indexed on 2010/06/10 15:12 UTC
Read the original article Hit count: 311

Filed under:
|
|

Hello.

I believe this may be a simple question, but I've looked everywhere and tried some workarounds, but I still haven't solved the problem.

Problem description: I have to replace a character inside a file and I can do it easily using the command line:

sed -e 's/pattern1/pattern2/g' full_path_to_file/file

But when I use the same line inside a bash script I can't seem to be able to replace it, and I don't get an error message, just the file contents without the substitution.

#!/bin/sh

VAR1="patter1"
VAR2="patter2"

VAR3="full_path_to_file"

sed -e 's/${VAR1}/${VAR2}/g' ${VAR3}

Any help would be appreciated.

Thank you very much for your time.

© Stack Overflow or respective owner

Related posts about bash

Related posts about sed