commandlinefu.com is the place to record those command-line gems that you return to again and again.
You can sign-in using OpenID credentials, or register a traditional username and password.
Subscribe to the feed for:
Strips comments from at least bash and php scripts. Normal # and // as well as php block comments
removes all of the:
lines beginning with #
lines beginning with //
lines beginning with /*
lines beginning with a space and then *
lines beginning with */
It also deletes the lines if there's whitespace before any of the above.
Add an alias to use in .bashrc like this:
alias stripcomments="sed -e '/^[[:blank:]]*#/d; s/[[:blank:]][[:blank:]]*#.*//' -e '/^$/d' -e '/^\/\/.*/d' -e '/^\/\*/d;/^ \* /d;/^ \*\//d'"