User Tools

Site Tools


computing:linux:strip_comments

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
computing:linux:strip_comments [2012/03/29 10:59]
gcooper
computing:linux:strip_comments [2015/10/19 10:00] (current)
gcooper
Line 1: Line 1:
 ====== Strip Comments ====== ====== Strip Comments ======
 +
 +===== With ''grep'' =====
 +
 +<file>
 +grep -v '^$\|^\s*\#' <filemane>
 +</file>
 +
 +===== Small Utility =====
 +
 +FIXME
  
 Create this tiny utility to view configuration files at their smallest and most readable form. Create this tiny utility to view configuration files at their smallest and most readable form.
Line 5: Line 15:
 Many support organizations insist you strip comments from config files to make them more readable. Many support organizations insist you strip comments from config files to make them more readable.
  
-Create, install and make the utility executable (cut and paste at the command line as root):+Create, install and make the utility executable (cut and paste the following at the command line as root):
  
 <file> <file>
 cat << EOF >> /usr/local/bin/nocom cat << EOF >> /usr/local/bin/nocom
 #!/bin/sh #!/bin/sh
-# nocom is a small tool to strip comments when viewing commented configuration files+'nocomis a small tool to strip comments when viewing commented configuration files 
 +# It's not perfect and may not work for you.  Note that it strips the initial "#!/bin/sh" too.
 # #
 echo "" echo ""
-cat $1 | sed -e '/^\s*;/d' | sed -e '/^\s*$/d'+cat \$1 | sed -e '/^\s*;/d' | sed -e '/^\s*\$/d' | sed -e '/^[[:blank:]]*#/d; s/[[:blank:]][[:blank:]]*#.*//'
 EOF EOF
  
computing/linux/strip_comments.1333040361.txt.gz · Last modified: 2012/03/29 10:59 by gcooper