LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 01-09-2013, 02:06 AM   #1
chuppi
LQ Newbie
 
Registered: Jan 2013
Location: bengaluru
Posts: 3

Rep: Reputation: Disabled
Post count total number of lines in a directory


hi all,

I need a shell script that should print total number of lines in a directory
E.g:- if i have directory(mydir)and that directory contains some files of .c & .h and some other directory(sample)that also have some files.

script should print number of lines of that directory and also sub folders & its files.the output should shows only number of lines(i.e 13245 lines in mydir)
 
Old 01-09-2013, 02:18 AM   #2
ruario
Senior Member
 
Registered: Jan 2011
Location: Oslo, Norway
Distribution: Slackware
Posts: 2,557

Rep: Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762
Read 'man find' and 'man wc' and you will see how to do it yourself.
 
Old 01-09-2013, 04:00 AM   #3
Satyaveer Arya
Senior Member
 
Registered: May 2010
Location: Palm Island
Distribution: RHEL, CentOS, Debian, Oracle Solaris 10
Posts: 1,420

Rep: Reputation: 305Reputation: 305Reputation: 305Reputation: 305
Code:
# ls | xargs wc -l
maybe this could help you.
 
Old 01-09-2013, 11:00 AM   #4
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Quote:
...I need a shell script that should print total number of lines in a directory ...
s/lines/files
 
Old 01-09-2013, 01:30 PM   #5
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
Is a subdirectory a 'line'? What about '.' and '..'?
Do you really mean something more like 'I want a recursive count of all files in a directory tree'?

--- rod.
 
  


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
Rename pdf files after their directory name and acoording to their total number IlIl7 Linux - Newbie 3 07-06-2012 04:09 PM
bash script to count number of lines with a specific property7 hhamid Programming 10 08-13-2010 01:35 AM
How to count total number of packages in entire Debian Distribution kushalkoolwal Debian 7 12-17-2008 01:37 PM
Count the number of files in a directory and sub-directories within that directory soumyajit.haldar Linux - Software 4 03-20-2007 06:22 AM
count total number of lines in several files xushi Programming 5 11-12-2005 04:42 PM

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

All times are GMT -5. The time now is 11:30 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