bash - Replace string in files using sed -


i have following sed command replace 1 string 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 replace 1 folder name , works fine. unfortunately need 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, not work. i've used "" instead of '' variables used , used , separator not need escape /.

what missing here?

you can try this,

sed -ie "s,$orig_cubes,$dest_cubes,g" $tmp_folder/data_sources/* 

Comments

Popular posts from this blog

Change php variable from jquery value using ajax (same page) -

Pull out data related to my apps from Android Play Store and iOS App Store -

How can I fetch data from a web server in an android application? -