Sunday, 24 November 2013

Remove comments and empty lines from config file

I'm tired to read big config files with lot of comments, especially when initial setting already done. The simple solution is to make a "clean" config file without any distracting lines:
Stop service
#service ldap stop
Make a backup copy - very important step :-)
#mv /etc/openldap/slapd.conf /etc/openldap/slapd.conf.20131124 
Copy only necessary lines to new config
#grep -v "^#" /etc/openldap/slapd.conf|grep -v "^$" >/etc/openldap/slapd.conf
Start service
#service ldap start
Don't forget to check that service started:
#service ldap status

Addition: Another command to remove comments and empty lines from the file

grep -Ev '^#|^$' file_name

No comments: