Removing Comments and Blank lines of a config file: Difference between revisions

From RSWiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
{{AdWords}}
Using 'grep' and 'sed' we can strip out comments and blank lines of any file. you can then redirect the output to a file if you so wish. In this example I will use it to remove the comments and blank lines from my apache2.conf file
Using 'grep' and 'sed' we can strip out comments and blank lines of any file. you can then redirect the output to a file if you so wish. In this example I will use it to remove the comments and blank lines from my apache2.conf file


  grep -v "#" /etc/apache2/apache2.conf | sed -e '/^$/d'
  grep -v "#" /etc/apache2/apache2.conf | sed -e '/^$/d'
If you wish to leave the blank lines then simply omit the sed statement.


If you wish to leave the blank lines then simply omit the sed statement.
{{AdWords2}}


[[Category:Linux| ]] [[Category:Unix| ]]
[[Category:Linux| ]] [[Category:Unix| ]]

Revision as of 18:57, 15 January 2008

Template:AdWords Using 'grep' and 'sed' we can strip out comments and blank lines of any file. you can then redirect the output to a file if you so wish. In this example I will use it to remove the comments and blank lines from my apache2.conf file

grep -v "#" /etc/apache2/apache2.conf | sed -e '/^$/d'

If you wish to leave the blank lines then simply omit the sed statement.

Template:AdWords2