|
Title: | How to replace strings in several Eloquence files? |
Document: | gen_039 |
Keywords: | shell script,replace strings,VOLUME,list,substitute |
I need to replace some strings in all of my Eloquence programs.
How do I proceed
To achive this, you might use a shellscript and the command sed. Before
you run the script you have to make a backup of all your files!
Assuming your *PROG files are at the current location. Please
create a file that contains all strings you want to substitute. If you intend
to substitute all Db$=" sampledb" with Db$=" server:eloqdb5/path/to/sampledb" the file
has the following content:
s~Db\$\=\" sampledb\"~Db\$\=\" server:eloqdb5/path/to/sampledb\"~g
The '\' before '$' and '=' is necessary to prevent sed of interpreting this
characters as special characters. It is valid to have up to 100 commands in the
file to use with sed (please refer to the sed man pages for details).
Save this fils as e.g. sub. Now create a shellscript with the following
content:
#!/bin/sh
cd test/
for prog in ../*.PROG
do
name=`basename $prog .PROG`
echo $name
list $prog | sed -f ../sub > $name
store $name
rm $name
done
Save this file as e.g. replace.sh and make it executable (chmod +x replace.sh).
Now you should create a directory called test:
mkdir ./test
and copy all program files into test
cp *PROG test/
If you run the script replace.sh, all substitution defined in the file sub will
take place.
|
|