LinuxQuestions.org
Review your favorite Linux distribution.
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 08-23-2004, 07:43 PM   #1
disorderly
Member
 
Registered: Sep 2003
Location: NJ
Distribution: RHEL5
Posts: 154

Rep: Reputation: 30
how to count files


hey there!

i was wondering is there is a way to count the number of files ending with a particular extension? what command can i use to count files? i was looking to find out how many webpages (*.html) there are on the disaster of a webserver i've inherited.

puzzled,
disorderly

Last edited by disorderly; 08-23-2004 at 08:20 PM.
 
Old 08-23-2004, 08:20 PM   #2
frob23
Senior Member
 
Registered: Jan 2004
Location: Roughly 29.467N / 81.206W
Distribution: OpenBSD, Ubuntu, FreeBSD
Posts: 1,449

Rep: Reputation: 48
ls *.htm | nl

That should do it... change .htm to the extension you need.
 
Old 08-23-2004, 08:37 PM   #3
disorderly
Member
 
Registered: Sep 2003
Location: NJ
Distribution: RHEL5
Posts: 154

Original Poster
Rep: Reputation: 30
aha good 'ol ls command- seems to only list the files in the present directory though. i tried adding -R to make it recursive but no good. any other ideas?

thanks!
disorderly
 
Old 08-23-2004, 09:45 PM   #4
frob23
Senior Member
 
Registered: Jan 2004
Location: Roughly 29.467N / 81.206W
Distribution: OpenBSD, Ubuntu, FreeBSD
Posts: 1,449

Rep: Reputation: 48
find ./ -name "*.htm" -print | nl
 
Old 08-23-2004, 09:53 PM   #5
ranger_nemo
Senior Member
 
Registered: Feb 2003
Location: N'rn WI -- USA
Distribution: Kubuntu 8.04, ClarkConnect 4
Posts: 1,142

Rep: Reputation: 47
If you want just the number, you can use " wc -l" instead of "nl". nl numbers the lines, which means if needs to print everything out. wc is word count, which just counts the lines with the -l option.
 
Old 08-24-2004, 01:36 PM   #6
disorderly
Member
 
Registered: Sep 2003
Location: NJ
Distribution: RHEL5
Posts: 154

Original Poster
Rep: Reputation: 30
hey that works great! exactly what i was looking for! thanks for your help guys

- disorderly
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
count total number of lines in several files xushi Programming 5 11-12-2005 04:42 PM
how to get count of files in a directory? hongxing Linux - Software 2 11-10-2005 09:06 PM
Count of two columns vimal480 Programming 1 04-16-2005 02:25 AM
Should posts in general count on your post count? Joey.Dale General 16 01-27-2004 01:31 AM
dd: bs=2X , count=?X adam_boz Linux - General 3 10-27-2002 07:18 PM


All times are GMT -5. The time now is 06:07 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration