LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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


Reply
  Search this Thread
Old 02-15-2010, 01:12 AM   #1
lipun4u
Member
 
Registered: Sep 2008
Location: Mumbai, india
Distribution: ubuntu and hp-unix
Posts: 118

Rep: Reputation: 15
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.
 
Old 02-15-2010, 01:34 AM   #2
Simon Bridge
LQ Guru
 
Registered: Oct 2003
Location: Waiheke NZ
Distribution: Ubuntu
Posts: 9,211

Rep: Reputation: 198Reputation: 198
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
 
Old 02-15-2010, 01:39 AM   #3
vinaytp
Member
 
Registered: Apr 2009
Location: Bengaluru, India
Distribution: RHEL 5.4, 6.0, Ubuntu 10.04
Posts: 707

Rep: Reputation: 55
Can you try this lipun4u,
Code:
wc `find . -type f | xargs ls -l | grep -v "^...x" | tr -s " " | cut -d " " -f 9` | more

Last edited by vinaytp; 02-15-2010 at 01:40 AM.
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to count occurrences of unique words in a file beeblequix Linux - General 8 06-05-2018 10:16 AM
How would I ignore other lines in a file with non unique words? btacuso Linux - Newbie 1 05-24-2009 08:20 AM
script to count lines kalimat Programming 16 12-15-2008 04:09 AM
Get all lines containing 23 specific words with AWK cgcamal Programming 3 11-05-2008 10:51 AM
how many lines and words (bash) sharapchi Programming 4 12-15-2006 12:45 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:39 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration