Unix/Linux 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 Linux or Unix Question    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 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 Unix and Linux 01-24-2013
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
 
Join Date: Feb 2004
Last Activity: 25 April 2015, 10:51 PM EDT
Location: NM
Posts: 10,434
Thanks: 328
Thanked 857 Times in 796 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 Unix and Linux 01-24-2013
DGPickett DGPickett is offline Forum Advisor  
Registered User
 
Join Date: Oct 2010
Last Activity: 17 February 2015, 1:56 PM EST
Location: Southern NJ, USA (Nord)
Posts: 4,671
Thanks: 8
Thanked 586 Times in 559 Posts
2097151 ?
    #4  
Old Unix and Linux 01-24-2013
Yoda's Unix or Linux Image
Yoda Yoda is offline Forum Advisor  
Jedi Master
 
Join Date: Jan 2012
Last Activity: 20 April 2015, 6:16 PM EDT
Location: Galactic Empire
Posts: 3,402
Thanks: 240
Thanked 1,216 Times in 1,142 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 Unix and Linux 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 Unix and Linux 01-24-2013
Yoda's Unix or Linux Image
Yoda Yoda is offline Forum Advisor  
Jedi Master
 
Join Date: Jan 2012
Last Activity: 20 April 2015, 6:16 PM EDT
Location: Galactic Empire
Posts: 3,402
Thanks: 240
Thanked 1,216 Times in 1,142 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 Unix and Linux 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 Linux or Unix Question

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Unix or Linux Image 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 03:26 PM.