PDA

View Full Version : [all variants] [SOLVED] find command // list folders with a expression



Plexus81
July 28th, 2008, 09:26 PM
How can I list all folders/subfolders with a spesific expression and a size bigger than 500 mb?

ex
want to find all folders / subfolder that have iso in their foldername and have a size bigger then 500 mb?

raptor2552
July 28th, 2008, 09:46 PM
Hello

You could use something like:

find / -size +500M -name *.iso

this will find starting at root all files 500meg or greater containing .iso

you may find all your looking for with man find

Plexus81
July 28th, 2008, 10:04 PM
I've tried many times but I can't get it to worp propebly.. I want:

total foldersize bigger than 500 MB
foldername with ex *iso* *ISO* like ignore case
and I want to list all the folder in the folder include subfolder like /../../test_iSo/

big thanx

sdennie
July 28th, 2008, 11:43 PM
If I understand you correctly, this should work:



find . -type d -size +500M | grep -i iso

raptor2552
July 29th, 2008, 01:47 AM
Sorry it took me so long to get back to you, but I had to eat + errands

This will find all directories 500MBytes or greater and list all the .iso under that directory if any


du -bS |awk '$1 > 500000000 {print "Size: " $1, "\tDir: " $2; system("ls -R "$2 "|grep -i iso") }'


if you would like to keep this in a script:
start gedit and then copy and paste this into the editor;


#!/bin/bash
du -bS |awk '$1 > 500000000 {print "Size: " $1, "\tDir: " $2; system("ls -R "$2 "|grep -i iso") }'

then save it to a directory in your path with a name you'll remember, home dir is preferable. Finally make it executable by typing:


chmod a+x yourscriptname

Let us know how/if this is what you're looking for:)

ghostdog74
July 29th, 2008, 02:04 AM
If I understand you correctly, this should work:



find . -type d -size +500M | grep -i iso


this should be equivalent to


find . -type d -size +500M -iname *iso*

sdennie
July 29th, 2008, 02:15 AM
this should be equivalent to


find . -type d -size +500M -iname *iso*


That's not an equivalent command. My command is also not correct in that it won't report subdirectories under an iso directory that are smaller than 500M though.

raptor2552
July 29th, 2008, 03:29 AM
Vor and ghostdog, I beg to differ with your solutions

Directories themselves have no real size except for the inode that describes the directory (4096 bytes). The files contained in the directories, the sum of their size, is what gives the directory their size.

Plexus81
July 29th, 2008, 08:37 AM
Sorry it took me so long to get back to you, but I had to eat + errands

This will find all directories 500MBytes or greater and list all the .iso under that directory if any


du -bS |awk '$1 > 500000000 {print "Size: " $1, "\tDir: " $2; system("ls -R "$2 "|grep -i iso") }'


if you would like to keep this in a script:
start gedit and then copy and paste this into the editor;


#!/bin/bash
du -bS |awk '$1 > 500000000 {print "Size: " $1, "\tDir: " $2; system("ls -R "$2 "|grep -i iso") }'

then save it to a directory in your path with a name you'll remember, home dir is preferable. Finally make it executable by typing:


chmod a+x yourscriptname

Let us know how/if this is what you're looking for:)

This is working perfect! Thanks alot! :)

sdennie
July 29th, 2008, 08:52 AM
Glad you were able to find a solution. :)