Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
hi there,
are you sure this is not your home work? if it is not i am sorry.
but if it is .... bad!
your solution
Code:
grep -c '^$' $YOURFILE
regards
slackie1000
[edit] man, terrible mistake.. you double posted in the same forum your homework! shame on you.
be less lazy and make it by yourself. i will just leave the solution here cause i think it is better than the other one provided in the other post. shame on you.. reported!
Last edited by slackie1000; 06-09-2005 at 05:47 AM.
If its easier to count [i]all[i] the lines in the file - you can use nl to count the non-blank lines and subtract.
More generally: in the "My LQ" box to the right, you see a link called: Edit Profile. Please use that to add your distro(s) and some sort of location. It helps you get better replies.
When you want to post a question, try sticking the question (maybe a short form) into the subject line. This way people know before they click on it, what you are asking. If this case, you could have put "how do I count blank lines using grep?" That would have fit. Better is to leave it open in case yu're barking up the wrong tree: something like "How do I count blank lines in txt file?" (This approach also makes you look smarter.)
If you go to the tutorials section, there are very helpful tutorials about how to post messages so you get the best answers.
Last edited by Simon Bridge; 06-09-2005 at 05:50 AM.
Please don't post homework questions. If you do, show us that you tried to do it yourself and have problems with details: manual page is not clear, you have written a script and it doesn't work etc.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.