LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   count lines and words (https://www.linuxquestions.org/questions/linux-newbie-8/count-lines-and-words-789163/)

lipun4u 02-15-2010 02:12 AM

count lines and words
 
How can I display the no. of lines, words and characters for each file in current directory and in sub directory.

wc . * shows errornous result as there are some executable files in that directory.

Simon Bridge 02-15-2010 02:34 AM

Sounds like homework.

You want your operation to skip non-text files - which means you'll need to put it in a script.
What is the difference between files that have words and lines to count and those which do not? Work out how to test for this and write your script accordingly.

The bash command "file" will probably help. You may also discover that all the valid files have some identifier in their name, like .txt

vinaytp 02-15-2010 02:39 AM

Can you try this lipun4u,
Code:

wc `find . -type f | xargs ls -l | grep -v "^...x" | tr -s " " | cut -d " " -f 9` | more


All times are GMT -5. The time now is 08:34 AM.