Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Linux
Hi,
 

I need to find the number of blank lines from a particular directory in all the files that ends with '.h' extension.
 

Thanks in advance
 
OP's additional information copied from comment below
First displayed all the .h files using the command ls /usr/include/ | grep '.h$'.
 
Now, I dont know how to proceed to open all those .h files and how to find blank lines.
 
I have tried grep -n ^$ filename | wc -l, to find the number of blank lines for a particular file.
 
But I need to know how to make both commands to work together. Please help.
Posted 17-Nov-12 21:23pm
srmohanr1.1K
Edited 19-Nov-12 5:39am
(no name)22.7K
v3
Comments
Richard MacCutchan at 18-Nov-12 4:39am
   
And what difficulty are you having in solving this problem?
Nelek at 18-Nov-12 8:13am
   
Please don't think we can read minds or do astral projections to see your monitor. If you need help, the least you could do is to add some relevant code to your question or to explain your problem in such a way, that the users of CP can understand it. Otherwise, nobody will be able to help you.
what have you tried?[^]
srmohanr at 19-Nov-12 1:02am
   
First dislayed all the .h files using the command ls /usr/include/ | grep '.h$'.
 
Now, I dont know how to proeceed to open all those .h files and how to find blank lines.
 
I have tried grep -n ^$ filename | wc -l, to find the number of blank lines for a particular file.
 
But I need to know how to make both commands to work together. Please help.
Sergey Alexandrovich Kryukov at 19-Nov-12 11:58am
   
C? C++? Tag it.
--SA
Sergey Alexandrovich Kryukov at 19-Nov-12 12:00pm
   
What have you so far? Such a trivial problem, but if you have some difficulties -- it's quite natural for beginners. Try to solve it by yourself and show your code. Explain what did you try, what happens, why do your thing it's wrong...
--SA
srmohanr at 19-Nov-12 23:19pm
   
I have tried to find the no. of blabk lines from all the .h files in a particular directory by using the command cat ../../usr/include/* | grep '^.h$'| grep ![a-z] | grep ![A-Z] | grep ![0-9] | grep ![`~!@#$%^&*()+=<>?:"{}|,./;'[]\] | wc -l
Richard MacCutchan at 19-Nov-12 14:24pm
   
wc -l counts total lines, not blank lines. You need to write a program to do this.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 475
1 Maciej Los 349
2 Richard MacCutchan 220
3 BillWoodruff 219
4 Mathew Soji 160
0 OriginalGriff 8,759
1 Sergey Alexandrovich Kryukov 7,407
2 DamithSL 5,639
3 Maciej Los 5,269
4 Manas Bhardwaj 4,986


Advertise | Privacy | Mobile
Web02 | 2.8.1411028.1 | Last Updated 19 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100