remove comments (even those starting with spaces), empty lines (even those containing spaces) in one grep command

grep -vE '^\s*(#|$)' textfile
useful for discarding even those comments which start with blanks or those empty lines which contain blanks
Sample Output
[[email protected] ~]# grep -vE '^\s*(#|$)' /etc/nsswitch.conf
passwd:     files sss
shadow:     files sss
group:      files sss
hosts:      files dns myhostname
bootparams: nisplus [NOTFOUND=return] files
ethers:     files
netmasks:   files
networks:   files
protocols:  files
rpc:        files
services:   files sss
netgroup:   nisplus sss
publickey:  nisplus
automount:  files nisplus sss
aliases:    files nisplus

What Others Think

Here the caption is something about remove comments (even those starting with spaces), empty lines (even those containing spaces) in one grep command. Are you up for cheap assignment writing service? It has nothing else except from an image so if you have any idea about the true meaning of it then explain it to me.
sadamn · 15 weeks ago
google
arvvaine · 14 weeks ago
[google](https://google.com)
arvvaine · 8 weeks and 6 days ago
http://www.google.org/">google
arvvaine · 8 weeks and 6 days ago
[MSN](http://search.msn.com/) [[http://www.edgewall.com|Edgewall Software]]
arvvaine · 8 weeks and 6 days ago
google
arvvaine · 8 weeks and 6 days ago
top resume review
arvvaine · 8 weeks and 6 days ago
One grep command has been doing well since its inception. Things related to comments are clear from this page. Comments can be removed for better results. Now you can check custom essay services to learn more new things to manage their story work. Empty spaces should be resolved. Thanks for sharing this with us.
Strickland1 · 6 weeks and 5 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: