LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 07-01-2004, 09:38 AM   #1
puzz_1
Member
 
Registered: May 2003
Posts: 49

Rep: Reputation: 15
How to count line numbers recursively in a directory?


HOw do i get the total line count in ALL the files in a particular diretory recursively?

I tried

cat * | wc -l

somehow this doesn't go into subdiretories and it doesn't ignore non-text files.
 
Old 07-01-2004, 09:43 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
Quote:
somehow this doesn't go into subdiretories and it doesn't ignore non-text files.
So this Somehow...

1) cat it a non recursive program...

2) cat doesn't distinguish between ascii and binary files. why should it?

you would want to possibly do a find on that directory (which IS recursive) and then use those results as the input to a for loop, which would include a 'test' command to check what kind of file it is.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to recursively rename files using their directory name pattern ceg4048 Linux - General 2 09-28-2005 01:16 PM
Recursively browse graphics on CD from command line ewto Linux - Software 1 03-11-2005 10:04 PM
Changing owner of a directory recursively? fturcic Linux - General 2 02-01-2005 07:13 AM
word count in a line pantera Programming 4 08-25-2004 01:14 PM
How to delete the first line of evrer .java file recursively ththomas Programming 2 03-08-2004 08:55 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 07:47 PM.

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