Unix/Linux Go Back    


UNIX for Dummies Questions & Answers This forum is closed for new posts. Please post beginner questions to learn unix and learn linux in this forum UNIX for Beginners Questions & Answers

Recursive Find on file size

UNIX for Dummies Questions & Answers


 
 
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: 10 December 2016, 10:37 PM EST
Location: NM
Posts: 10,882
Thanks: 459
Thanked 988 Times in 918 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: 1 February 2016, 3:35 PM EST
Location: Southern NJ, USA (Nord)
Posts: 4,673
Thanks: 8
Thanked 587 Times in 560 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: 5 December 2016, 4:51 PM EST
Location: Galactic Empire
Posts: 3,529
Thanks: 248
Thanked 1,281 Times in 1,203 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: 5 December 2016, 4:51 PM EST
Location: Galactic Empire
Posts: 3,529
Thanks: 248
Thanked 1,281 Times in 1,203 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
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux 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 08:48 AM
How to find the latest file on Unix or Linux (recursive) 1or2is3 Shell Programming and Scripting 7 02-27-2011 07:07 PM
find with file size and show the size rpraharaj84 Shell Programming and Scripting 3 10-06-2009 02:42 PM
command to find out total size of a specific file size (spread over the server) abhinov Solaris 3 08-08-2007 07:48 AM
find file with date and recursive search for a text rosh0623 UNIX for Advanced & Expert Users 10 08-16-2006 03:27 PM



All times are GMT -4. The time now is 09:47 AM.