I have a path say ==========================
/nfs/old_home/dexter/work/Deamon/Test2/IN/
Inside this path i have script files say: Files1.sh Files2.sh Flles3.sh ....
Filesn.sh
Each of these script files have a line say
export DATABASE_XML=/mnt/nfs/lin_work_live/linear_work/dexter/Deamon/Test2/RDB.xml
===================================================== So say the first path i.e. /nfs/old_home/dexter/work/Deamon/Test2/ has this RDB.xml file and the path Given in that Script file i.e. export DATABASE_XML=**/mnt/nfs/lin_work_live/linear_work/dexter/Deamon/Test2/**RDB.xml is the linked path.
So If i move the script files from say /nfs/old_home/dexter/work/Deamon/Test2/IN/ to /nfs/old_home/dexter/work/Deamon/Test3/IN/ so it should read the RDB.xml file of the /nfs/old_home/dexter/work/Deamon/Test3/ directory and not the Test2..in 1 simple word the path inside the scripts export DATABASE_XML=/mnt/nfs/lin_work_live/linear_work/dexter/Deamon/Test2/RDB.xml Should change to Test3 also this change should reflect in all the File1.sh...FileN.sh files i move. Hope this is much clear now??
restatement of the problem
/orig
/orig/conf
/orig/IN/script1
../orig/IN/scriptN
export VAR="/orig-sym/conf"
/orig-sym
is a symbolic link to/orig
/new
/orig/conf
to/new/conf
/orig/IN/scriptX
to/new/IN/scriptX
export VAR="/new-sym/conf"
/new-sym
is a symbolic link to/new
solution 1
Do a search & replace on the files
scriptX
after they have been moved.Something along the lines of
sed -i s/find/replace/ file*
can work but care must be taken to surereplace
does not contain characters that are special to sed (eg./
,[
, etc). Quoting these safely can be complicated.However, we can sidestep the issue. For example, using the shell and perl:
/new-sym
)-i
overwrites filesBEGIN
copies the new path avoiding the escaping complicationss///
performs the replacementsolution 2
Don't use absolute paths.
As the configuration file is always one level up from the scripts, relative paths won't need to be changed.
If the script is executed directly,
$0
should contain its path. So in many situations, something like this will work: