Recursive Find on file size | Unix Linux Forums | UNIX for Dummies Questions & Answers

  Go Back    


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 !!

Recursive Find on file size

UNIX for Dummies Questions & Answers


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 01-24-2013
jimbojames jimbojames is offline
Registered User
 
Join Date: May 2011
Last Activity: 28 April 2014, 11:52 PM EDT
Posts: 47
Thanks: 12
Thanked 0 Times in 0 Posts
Recursive Find on file size

Is there a way to use the find command to recursively scan directories for files greater than 1Gb in size and print out the directory path and file name only?

Thanks in advance.
Sponsored Links
    #2  
Old 01-24-2013
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
 
Join Date: Feb 2004
Last Activity: 28 August 2014, 5:04 PM EDT
Location: NM
Posts: 10,180
Thanks: 275
Thanked 785 Times in 734 Posts
Some versions of find support extra values for files sizes this is generic
1953125 by 512 byte blocks = 1GB, this produces tow columns = directory name and filename


Code:
find /path -size +1953125 -print |
while read fname 
do
   echo "$(dirname $fname)    $(basename $fname)"
done

Sponsored Links
    #3  
Old 01-24-2013
DGPickett DGPickett is offline Forum Advisor  
Registered User
 
Join Date: Oct 2010
Last Activity: 29 August 2014, 5:00 PM EDT
Location: Southern NJ, USA (Nord)
Posts: 4,409
Thanks: 8
Thanked 538 Times in 516 Posts
2097151 ?
    #4  
Old 01-24-2013
Yoda's Avatar
Yoda Yoda is offline Forum Advisor  
Jedi Master
 
Join Date: Jan 2012
Last Activity: 29 August 2014, 5:55 PM EDT
Location: Galactic Empire
Posts: 3,362
Thanks: 230
Thanked 1,197 Times in 1,125 Posts
If you have GNU find available then use:

Code:
find . -type f -size +1G

Check your find version:

Code:
find --version
GNU find version 4.2.27

Sponsored Links
    #5  
Old 01-24-2013
jimbojames jimbojames is offline
Registered User
 
Join Date: May 2011
Last Activity: 28 April 2014, 11:52 PM EDT
Posts: 47
Thanks: 12
Thanked 0 Times in 0 Posts
Thanks jim mcnamara, that is great. Do you know if it can be enhanced so that only the directories/files that the executing user id has access to are returned? ie, if a
Quote:
: The file access permissions do not allow the specified action.
error is returned, it won't be displayed in the list?

bipinajith, if I type
Quote:
find --version
I get the following error
Quote:
Usage: find [-H | -L] path-list [predicate-list]
Thanks for your help guys!
Sponsored Links
    #6  
Old 01-24-2013
Yoda's Avatar
Yoda Yoda is offline Forum Advisor  
Jedi Master
 
Join Date: Jan 2012
Last Activity: 29 August 2014, 5:55 PM EDT
Location: Galactic Empire
Posts: 3,362
Thanks: 230
Thanked 1,197 Times in 1,125 Posts
Ok, that means you do not have GNU find

You can suppress the error messages by redirecting stderr to /dev/null

Code:
find /path -size +1953125 -print 2> /dev/null

Sponsored Links
    #7  
Old 01-24-2013
jimbojames jimbojames is offline
Registered User
 
Join Date: May 2011
Last Activity: 28 April 2014, 11:52 PM EDT
Posts: 47
Thanks: 12
Thanked 0 Times in 0 Posts
Thanks bipinajith, that is perfect!
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Recursive find / grep within a file / count of a string Charlie6742 Shell Programming and Scripting 9 12-04-2012 07:48 AM
How to find the latest file on Unix or Linux (recursive) 1or2is3 Shell Programming and Scripting 7 02-27-2011 06:07 PM
find with file size and show the size rpraharaj84 Shell Programming and Scripting 3 10-06-2009 01:42 PM
command to find out total size of a specific file size (spread over the server) abhinov Solaris 3 08-08-2007 06:48 AM
find file with date and recursive search for a text rosh0623 UNIX for Advanced & Expert Users 10 08-16-2006 02:27 PM



All times are GMT -4. The time now is 12:14 AM.