I related your last two post, and i tried the following..
Hope this will remove your blocking...
$cat file
DEV_1_SOURCE_DATABASE=server1
DEV_1_SOURCE_AUDIT_DATABASE= server1
DEV_1_TARGET_DATABASE=server4
DEV_1_TARGET_AUDIT_DATABASE=server4
DEV_2_SOURCE_DATABASE=server2
DEV_2_SOURCE_AUDIT_DATABASE= server2
DEV_2_TARGET_DATABASE=server5
DEV_2_TARGET_AUDIT_DATABASE=server5
Solution 1:
script1.sh
a=` cat file | grep -w "DEV_2_TARGET_DATABASE" | cut -d '=' -f 2`
sed "s/\($a\)/newdb/g" file > file1
mv file1 file
The above script will take the value assigned for DEV_2_TARGET_DATABASE, and substitute that value i.e "server5" to newdb in the whole file content. ( even for DEV 4 or DEV 3)
Solution 2:
If you want to substitute only DEV_2_TARGET_DATABASE=server5 to DEV_2_TARGET_DATABASE=newdb
sed "s/\(DEV_2_TARGET_DATABASE=\)\(.*\)/\1newdb/g" file
Hope this helps..