I have a pretty specific problem. I am trying to delete certain lines out of a server configuration file based on a keyword find. If you scroll down the code below at the bottom, I am trying to delete the block of code that has the keyword "nasdaq" in the directory line. This includes everything from the "database" line all the way to the bottom where it reads "index termName pres, eq".
What is the best way I can go about this? String.find()
? What commands should I use to delete lines above and below the keyword line?
Also, I could either delete the lines or just write to a new file and ignore the last block. Some guidance needed!
include /home/tuatara/TuataraServer-2.0/etc/openldap/schema/core.schema
include /home/tuatara/TuataraServer-2.0/etc/openldap/schema/cosine.schema
include /home/tuatara/TuataraServer-2.0/etc/openldap/schema/inetorgperson.schema
include /home/tuatara/TuataraServer-2.0/etc/openldap/schema/tuatara.schema
pidfile /home/tuatara/TuataraServer-2.0/var/slapd.pid
argsfile /home/tuatara/TuataraServer-2.0/var/slapd.args
database ldbm
loglevel 0
directory /home/tuatara/TuataraServer/var/openldap-ldbm-CMDB-spellchecker-20130106-06_20_31_PM
suffix "o=CMDB-spellchecker"
suffix "dc=CMDB-spellchecker,dc=com"
rootdn "cn=admin,o=CMDB-spellchecker"
rootpw tuatara
schemacheck on
lastmod off
sizelimit 100000
defaultaccess read
dbnolocking
dbnosync
cachesize 100000
dbcachesize 1000000
dbcacheNoWsync
index objectclass pres,eq
index default pres,eq
index termName pres,eq
database ldbm
loglevel 0
directory /home/tuatara/TuataraServer/var/openldap-ldbm-CMDB-spellchecker.medicinenet-20130106-06_20_31_PM
suffix "o=CMDB-spellchecker.medicinenet"
suffix "dc=CMDB-spellchecker.medicinenet,dc=com"
rootdn "cn=admin,o=CMDB-spellchecker.medicinenet"
rootpw tuatara
schemacheck on
lastmod off
sizelimit 100000
defaultaccess read
dbnolocking
dbnosync
cachesize 100000
dbcachesize 1000000
dbcacheNoWsync
index objectclass pres,eq
index default pres,eq
index termName pres,eq
database ldbm
loglevel 0
directory /home/tuatara/TuataraServer/var/openldap-ldbm-CMDB-nasdaq-20131127-12_37_43_PM
suffix "o=CMDB-nasdaq"
suffix "dc=CMDB-nasdaq,dc=com"
rootdn "cn=admin,o=CMDB-nasdaq"
rootpw tuatara
schemacheck on
lastmod off
sizelimit 100000
defaultaccess read
dbnolocking
dbnosync
cachesize 100000
dbcachesize 100000000
dbcacheNoWsync
index objectclass pres,eq
index default pres,eq
index termName pres,eq