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
script to find the average number or files? bbbngowc Shell Programming and Scripting 2 03-27-2008 08:57 AM
To find pid from port number gmat HP-UX 6 12-31-2007 03:43 AM
awk script to find the number of files uni_ajay_r Shell Programming and Scripting 4 10-31-2006 02:58 PM
how to find serial number chomca AIX 3 05-26-2006 07:00 AM
How to find number of processes ? ArabOracle.com SUN Solaris 2 02-13-2006 11:29 PM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-05-2007
Registered User
 

Join Date: Sep 2007
Posts: 7
how to find the number of files

hi,

1) I want to find from the current directory the number of files (count) with two or more particular extentions in another directory.

For ex: If I am in a/b/c directory... I want to find the count of the files with .txt and .dat extention in a/d/e directory. I have tried using the below one:

a/b/c> ls a/d/e/*.txt *.dat | wc -l --- this is not working.. Please help.

2) In the above directory a/d/e, i want to get the name of the last file with extention *.dat-- how to get it

Thanks in advance,
Harish
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 10-05-2007
Registered User
 

Join Date: Feb 2005
Posts: 68
Try this

ls | wc -l
Reply With Quote
  #3 (permalink)  
Old 10-05-2007
Registered User
 

Join Date: Oct 2007
Posts: 34
do this

Harish,

do this.this shud work


find a/d/e/ -type f \( -name "*.txt" -o -name "*.dat" \) | xargs ls -l | wc -l


all the best.


cheers,
Devaraj Takhellambam
Reply With Quote
  #4 (permalink)  
Old 10-06-2007
Technorati Master
 

Join Date: Mar 2005
Location: Large scale systems...
Posts: 2,475
Quote:
a/b/c> ls a/d/e/*.txt *.dat | wc -l
this would display *.txt files from a/d/e and *.dat files from a/b/c

try this

Code:
ls a/d/e/*.txt a/d/e/*.dat
Reply With Quote
  #5 (permalink)  
Old 10-07-2007
Registered User
 

Join Date: Sep 2007
Posts: 7
Quote:
Originally Posted by devtakh View Post
Harish,

do this.this shud work


find a/d/e/ -type f \( -name "*.txt" -o -name "*.dat" \) | xargs ls -l | wc -l


all the best.


cheers,
Devaraj Takhellambam
Thanks man... its working.. can you answer the 2nd query tooo ...
Reply With Quote
  #6 (permalink)  
Old 10-09-2007
Technorati Master
 

Join Date: Mar 2005
Location: Large scale systems...
Posts: 2,475
Code:
ls -lrt a/d/e/*.dat | awk 'END{print}'
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 06:58 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0