The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #2 (permalink)  
Old 08-18-2005
hadarot hadarot is offline
Registered User
  
 

Join Date: Jul 2005
Posts: 33
If you want to do only a couple things with the output, filter you source file in a pipeline:
Code:
grep -v '^[[:space:]]*#' /path/to/your/file | your_commands
if you want do extensive stuff with your comment-stripped file, save the stripped file in a temp file, and use use the temp file for the rest of the procedure:
Code:
grep -v '^[[:space:]]*#' /path/to/your/file  >/tmp/stripped_source
Note that I use ^[[:space:]]* at the start of the regular expression because lines that are completely comments can still contain leading whitespace. If you want to eliminate blank lines also, do
Code:
 egrep -v '(^[[:space:]]*#|^[[:space:]]*$)' /path/to/file >/tmp/stripped_file

Last edited by hadarot; 08-18-2005 at 08:53 PM..