replacing text with text

I have 2 variables in a script
$base_dir
$install_dir

I have a file with output like this:
/home/matt/1
/home/matt/2
/home/matt/3
/home/matt/5

/home/matt is stored in $base_dir which
does not necessarily have to hold /home/matt.

I want to replace /home/matt with the contents of $install_dir

Using sed i thought it would look like this:
sed 's/$base_dir/$install_dir/g' myfile1 >myfile2

but it doesn't work. (i don't think sed accepts variables)

How can it be done??
SothAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
ozoConnect With a Mentor Commented:
"" to allow shell variable expansion,
s||| (or other unused character) to allow / inside of the expression
0
 
SothAuthor Commented:
my scripts use #!/bin/sh

0
 
ozoCommented:
sed "s|$base_dir|$install_dir|g"  myfile1 >myfile2
0
 
SothAuthor Commented:
you are a god damn genius
answer and recieve your prize

0
All Courses

From novice to tech pro — start learning today.