sed 's:=/.*:=/test/path:' file
例子:
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
如果要原地更改,请添加-i
编辑评论:
sed 's@\(^EMS_[SIJ].*=/\).*@\1test/path/@' file
同样的例子:
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