[Novalug] Comment and blank line stripping. (Was: Printing question)
Kevin Cole
dc.loco at gmail.com
Sun Dec 9 10:06:58 EST 2007
On Dec 8, 2007 6:23 PM, Justin Swain <justin.swain at gmail.com> wrote:
> One method is to be at vi's command ":" then enter . . .
> g/[...]d<CR>
>
> . . . where <CR> equals Line feed Carage Return
>
> . . . this operation deletes the blank lines on my Unix box. :-) Justin
Although not exactly what you want, Justin's comment reminded me of
something I've been meaning to share. All you regexp guru's may stop
reading now, but I've had this handy little alias in my bashrc for
quite a while:
alias decomment='egrep -v "^[[:space:]]*(#.*)?$" '
This removes comment lines and blank lines from files using the # as
the comment introducer. The above comes in mighty handy when looking
at config files where every possible option is included as a comment,
and you're only interested in looking at the "active" lines -- usually
4 lines in a 2000+ line file. ;-)
(No doubt it could stand improvement, by changing it from an alias to
a script that accepts an argument for the comment delimiter... among
other things.)
--
Ubuntu Linux DC LoCo
Washington, DC
http://dc.ubuntu-us.org/
More information about the Novalug
mailing list