Reputation: 1527
I have a file called test and it contains:
EMS_INSTANCES_DIR=/WEB_DATA/home/edofc24/EMS-INSTANCES/async
EMS_SHARED_CONFIG=/WEB_DATA/home/edofc24/EMS-INSTANCES/async/shared/config
EMS_SHARED_DATA=/WEB_DATA/home/edofc24/EMS-INSTANCES/async/shared/data
EMS_JMS_PORT=15244
EMS_INTERFACE=tcp://adecpcas:15244
EMS_KEYS=/WEB_DATA/home/edofc24/EMS-INSTANCES/keys
and I want to change the path after = to /test/path
I use sed
to do that:
sed 's/\(^EMS_[SIJ].*\=\)\(\/.*[a-z]$\)/\1\/test/path/' test
but no changes happened, why?.
Upvotes: 0
Views: 75
Reputation: 195179
sed 's:=/.*:=/test/path:' file
example:
kent$ echo "EMS_INSTANCES_DIR=/WEB_DATA/home/edofc24/EMS-INSTANCES/async
EMS_SHARED_CONFIG=/WEB_DATA/home/edofc24/EMS-INSTANCES/async/shared/config
EMS_SHARED_DATA=/WEB_DATA/home/edofc24/EMS-INSTANCES/async/shared/data
EMS_JMS_PORT=15244
EMS_INTERFACE=tcp://adecpcas:15244"|sed 's:=/.*:=/test/path:'
EMS_INSTANCES_DIR=/test/path
EMS_SHARED_CONFIG=/test/path
EMS_SHARED_DATA=/test/path
EMS_JMS_PORT=15244
EMS_INTERFACE=tcp://adecpcas:15244
if you want to change in place, add -i
EDIT for the comment:
sed 's@\(^EMS_[SIJ].*=/\).*@\1test/path/@' file
with same example:
kent$ echo "EMS_INSTANCES_DIR=/WEB_DATA/home/edofc24/EMS-INSTANCES/async
EMS_SHARED_CONFIG=/WEB_DATA/home/edofc24/EMS-INSTANCES/async/shared/config
EMS_SHARED_DATA=/WEB_DATA/home/edofc24/EMS-INSTANCES/async/shared/data
EMS_JMS_PORT=15244
EMS_INTERFACE=tcp://adecpcas:15244"|sed 's@\(^EMS_[SIJ].*=/\).*@\1test/path/@'
EMS_INSTANCES_DIR=/test/path/
EMS_SHARED_CONFIG=/test/path/
EMS_SHARED_DATA=/test/path/
EMS_JMS_PORT=15244
EMS_INTERFACE=tcp://adecpcas:15244
Upvotes: 1