Sunday, August 4, 2013

Removing commented lines and display

grep -v '^#' samba.conf 
here -v is for inverse 
ie -v, --invert-match
              Invert the sense of matching, to select non-matching lines.
Will print all lines EXCEPT those that begin with a # char. 
you can change the comment char to whatever you wish.
 
egrep -v '^(;|#|//)' filelist 
If you have more than one comment char , use the above command 
 
 
In regex, ^ indicates the beginning of a line, and $ the end of a line,
So ^$ specifies lines where the start of line character and the end of line character are right next to each other.
 

No comments: