mongod.conf file
# mongod.conf
# for documentation of all options, see:
# http://docs.mongodb.org/manual/reference/configuration-options/
# Where and how to store data.
storage:
dbPath: /var/lib/mongodb
journal:
enabled: true
# engine:
# mmapv1:
# wiredTiger:
# where to write logging data.
systemLog:
destination: file
logAppend: true
path: /var/log/mongodb/mongod.log
# network interfaces
net:
port: 27017
bindIp: 127.0.0.1
#processManagement:
#security:
#operationProfiling:
#replication:
#sharding:
## Enterprise-Only Options
#auditLog:
#snmp:
This is the mongoDB configuration file I have, I need to Update keys in the file like this,
port: 27017
bindIp: 0.0.0.0
#security:
keyFile:/opt/mongodb/keyfile
authorization: enabled
#replication:
replSetName: mongoreplica1
How can I do this using bash script?
You may fix the sed
command using
sed -i 's/^\( *bindIp *: *\).*/\10.0.0.0/'
The BRE POSIX pattern ^\\( *bindIp *: *\\).*
matches
^
- start of string \\( *bindIp *: *\\)
- Capturing group #1 (referred to with \\1
from the RHS): zero or more spaces, bindIp
, zero or more spaces, :
and zero or more spaces .*
- rest of the line
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.