Prints a file leaving out all blank lines and comment-only lines

egrep -v "^\s*(#|$)" myfile.cfg
Does not print any line that either: - is empty - contains only spaces or tabs - starts with # - starts with spaces/tabs followed by a #

By: dan
2011-12-08 15:25:17

What Others Think

You got your useless cat award. Congratulations
zolden · 515 weeks and 3 days ago
This, instead of dumping only lines containing only whitespace, will dump lines containing only "s". Probably not real useful, but you never know. :-)
trapperb · 515 weeks and 3 days ago
Might be useful for boring configs with lots of comments, but as pointed above it needs backslash before that s because, currently it does NOT do what description says.
mwgamera · 515 weeks ago
For some reason the backslash does not show up. Here's the command: cat boring.conf | egrep -v "^\s*(#|$)"
dan · 514 weeks and 6 days ago
Or: egrep -v "^\s*(#|$)" boring.conf No need for cat(1).
atoponce · 513 weeks and 6 days ago
Thanks @atoponce, much better. I've modified the command.
dan · 513 weeks and 4 days ago
Extremely helpful post. This is my first time i visit here. I discovered such a large number of intriguing stuff in your blog particularly its exchange. Truly its extraordinary article. Keep it up. N95 mask
jackson2321 · 11 weeks and 6 days ago
You make so many great points here that I read your article a couple of times. Your views are in accordance with my own for the most part. This is great content for your readers. ??
jackson2321 · 11 weeks and 3 days ago
Your source for the wholesale custom water purifier, air purifier, water hydrogen machine at a competitive price. Purificador de ar de Olansi
KayGasaway · 11 weeks and 3 days ago
Impressive web site, Distinguished feedback that I can tackle. Im moving forward and may apply to my current job as a pet sitter, which is very enjoyable, but I need to additional expand. Regards. Pi Email
KayGasaway · 10 weeks and 5 days ago
This is certainly hence attractive plus artistic. I like a colorations plus whichever company may get them while in the mailbox might be smiling.
KayGasaway · 10 weeks and 1 day ago
It's great that you have the urge to help students like me. Keep it up. Irvine Concrete Pros
OwenThatcher · 8 weeks and 5 days ago
Thanks for taking the time to discuss that, I feel strongly about this and so really like getting to know more on this kind of field. Do you mind updating your blog post with additional insight? It should be really useful for all of us. Goldshell lt5 pro for sale
KayGasaway · 8 weeks and 4 days ago
Great job for publishing such a beneficial web site. Your web log isn’t only useful but it is additionally really creative too. There tend to be not many people who can certainly write not so simple posts that artistically. Continue the nice writing site de streaming
KayGasaway · 8 weeks and 1 day ago
Very efficiently written information. It will be beneficial to anybody who utilizes it, including me. Keep up the good work. For sure i will check out more posts. This site seems to get a good amount of visitors. ?????????????
KayGasaway · 7 weeks and 6 days ago
Your article is extremely helpful exceptionally fascinating subject i am looking that sort of post thank for imparting to us keep it up. ???????
KayGasaway · 7 weeks and 2 days ago
enamel badges made to order, Badge Creation make all types of badges and lapel pins, enamel and printed. Call us on 0845 299 6550
KayGasaway · 5 weeks and 2 days ago
I’m going to read this. I’ll be sure to come back. thanks for sharing. and also This article gives the light in which we can observe the reality. this is very nice one and gives indepth information. thanks for this nice article... ???????????
jackson2321 · 5 weeks and 1 day ago
This is my first time visit to your blog and I am very interested in the articles that you serve. Provide enough knowledge for me. Thank you for sharing useful and don't forget, keep sharing useful info: Autolikes
KayGasaway · 5 weeks ago
If you are looking for more information about flat rate locksmith Las Vegas check that right away. Hochschule Hamm Lippstadt
Joshua4524 · 4 weeks and 3 days ago
Great article Lot's of information to Read...Great Man Keep Posting and update to People..Thanks
hanry · 4 weeks and 1 day ago
I really like your blog. Great article. It's most evident, people should learn before they are able to">thc wax
jackson2321 · 3 weeks and 6 days ago
You make so many great points here that I read your article a couple of times. Your views are in accordance with my own for the most part. This is great content for your readers. visit the site
jackson2321 · 3 weeks and 1 day ago
We are truly thankful for your blog entry. You will discover a great deal of methodologies in the wake of going to your post. I was precisely scanning for. A debt of gratitude is in order for such post and please keep it up.  Fun88
jackson2321 · 2 weeks and 6 days ago
First You got a great blog .I will be interested in more similar topics. i see you got really very useful topics, i will be always checking your blog thanks. thc dabs for sale
jackson2321 · 2 weeks and 5 days ago
This is my first time visit here. From the tons of comments on your articles,I guess I am not only one having all the enjoyment right here! "e?cinsel Filmleri izle":
hanry · 2 weeks and 1 day ago
Thanks for your insight for your fantastic posting. I’m glad I have taken the time to see this.
hanry · 1 week and 6 days ago
En nuestra web puedes encontrar pisos baratos donde entrar a vivir, te asesoraremos en todo lo que necesites. Terreno en venta en tenerife
hanry · 1 week and 5 days ago
Shanghai Pamaens Technology Co., Ltd specializes in the R&D, production and sales of energy-saving heating and insulation products, training and after-sale one-stop service. Infrared ceramic heater
hanry · 1 week and 4 days ago
Watchessy is a OEM & ODM watches manufacturer & supplier in China which can provide watches wholesale. We are your one-stop-shop solution to custom watch design,watch manufacturing and Watch necessaries(box,tag ,booklet,watch tool and so on). We also make private label watches based on customer's design or idea.Our designer will draw the engineering file and picture for you to check . And we can provide the necessary certificates like CE,Rohs which our customer require. We have our own factory,production and assembly with 10 years watch experience.Swiss Ronda,Japanese Miyota,Seiko movement is our watch movement supplier. Our warranty is at least one year. wholesale watches
hanry · 1 week and 4 days ago
Extremely pleasant article, I appreciated perusing your post, exceptionally decent share, I need to twit this to my adherents. Much appreciated!.  check that
jackson2321 · 1 week and 2 days ago
If you don"t mind proceed with this extraordinary work and I anticipate a greater amount of your magnificent blog entries.  buy thc oil online
jackson2321 · 1 week and 1 day ago
Most of the time I don’t make comments on websites, but I'd like to say that this article really forced me to do so. Really nice post! ????? mm88
jackson2321 · 5 days ago
I think this is definitely an amazing project here. So much good will be coming from this project. The ideas and the work behind this will pay off so much. ?????
jackson2321 · 4 days ago
I really like your blog. Great article. It's most evident, people should learn before they are able to ?????
jackson2321 · 4 days ago
Hi there, I found your blog via Google while searching for such kinda informative post and your post looks very interesting for me. Canninghill Piers
jackson2321 · 4 days ago
I definitely enjoying every little bit of it. It is a great website and nice share. I want to thank you. Good job! You guys do a great blog, and have some great contents. Keep up the good work. chs fairmont
jackson2321 · 4 days ago
I truly welcome this superb post that you have accommodated us. I guarantee this would be valuable for the vast majority of the general population. ??????
jackson2321 · 2 days ago
A lot of people having an incorrect image about the cash advance loans or sometimes refer it as bad credit payday loans. ??????????????
jackson2321 · 2 days ago
Incredible articles and awesome design. Your blog entry merits the greater part of the positive input it"s been getting. ???
jackson2321 · 2 days ago
Nothing compares to Weber using Genesis sort of grills. That is certainly the type gas grills which have been that will always make sure that they deliver a high performance part of down interval here
jackson2321 · 1 day ago
I want to say thanks for beautiful blog sharing with us. Your blog really great resource to update my knowledge. cat food flavor enhancers
jackson2321 · 15 hours ago
Excellent .. Amazing .. I’ll bookmark your blog and take the feeds also…I’m happy to find so many useful info here in the post, we need work out more techniques in this regard, thanks for sharing.  immobilien kaufen
jackson2321 · 12 hours 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? 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.


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: