1

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?

1 Answer 1

1

You can try with this,

sed -iE "s,$ORIG_CUBES,$DEST_CUBES,g" $TMP_FOLDER/data_sources/*
Sign up to request clarification or add additional context in comments.

1 Comment

It works also without E: sed -i "s,$ORIG_CUBES,$DEST_CUBES,g" $TMP_FOLDER/data_sources/*

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.