Reputation: 22661
I do have the following sed
command to replace one string with another in many files:
sed -i 's/\/mnt\/disk-K\/99990_Analytics\/30000_OLAP\/31000_Cube\//\/home\/tgr\/Applications\/Saiku\/saiku-server\/tomcat\/webapps\/saiku\/WEB-INF\/classes\/foodmart\//g' /home/tgr/Applications/Saiku/tmp_data/data_sources/*
It should just replace one folder name with another and it works fine. Unfortunately I need to have variables instead of manually escaped strings in command. I've tried:
ORIG_CUBES="/mnt/disk-K/99990_Analytics/30000_OLAP/31000_Cube/"
DEST_CUBES="/home/tgr/Applications/Saiku/saiku-server/tomcat/webapps/saiku/WEB-INF/classes/foodmart/"
TEMP_FOLDER="/home/tgr/Applications/Saiku/tmp_data"
sed -i "s\,$ORIG_CUBES,$DEST_CUBES,g" $TMP_FOLDER/data_sources/*
Unfortunately, this does not work. I've used "" instead of '' so variables are used and used ,
as separator so I do not need escape /
.
What am I missing here?
Upvotes: 1
Views: 3222
Reputation: 14969
You can try with this,
sed -iE "s,$ORIG_CUBES,$DEST_CUBES,g" $TMP_FOLDER/data_sources/*
Upvotes: 1