The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
row count of all files with more than 0 byte sri2005 UNIX for Dummies Questions & Answers 6 04-29-2008 06:39 PM
Count files lines in a directory? davidoff Shell Programming and Scripting 13 04-08-2008 03:04 AM
Display the count of files wayne1411 Shell Programming and Scripting 4 01-09-2008 10:09 PM
count of files mahalakshmi Shell Programming and Scripting 13 11-28-2006 09:01 AM
command to count files in dir balireddy_77 Shell Programming and Scripting 4 11-15-2006 01:56 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 12-28-2007
keymind keymind is offline
Registered User
  
 

Join Date: Dec 2007
Posts: 2
Provide a count of files

Hi,

I'm a unix newbie and need your help.

I need to get a count of files on our server. Number of .html files, Number of .pdf's, and Number of .ppt.

I tried:

find . -type f | wc -l

but it only give me a total count.

Thanks.
  #2 (permalink)  
Old 12-28-2007
frank_rizzo frank_rizzo is offline Forum Advisor  
Resident BOFH
  
 

Join Date: Dec 2007
Posts: 426

Code:
find . -name \*.pdf|wc -l
find . -name \*.html|wc -l
...

  #3 (permalink)  
Old 12-28-2007
keymind keymind is offline
Registered User
  
 

Join Date: Dec 2007
Posts: 2
Great! That worked.

Is there a way to exclude a directory?

Thanks for your quick response.
  #4 (permalink)  
Old 12-28-2007
RTM's Avatar
RTM RTM is offline Forum Advisor  
Hog Hunter
  
 

Join Date: Apr 2002
Location: On my motorcycle
Posts: 3,039
Add your -type f back in the mix
  #5 (permalink)  
Old 12-30-2007
VISH VISH is offline
Registered User
  
 

Join Date: Dec 2007
Posts: 2
u can use something like this find \*.{pdf,ppt} | wc -l

but it will not work bourne shell
  #6 (permalink)  
Old 12-30-2007
ghostdog74 ghostdog74 is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2006
Posts: 2,555

Code:
find /home -type f | awk 'BEGIN{ FS="[/.]"}
{
 ext[$NF]++
}
END{
   print "No. of counts for pdf files is " ext["pdf"]
}'

Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 02:33 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0