-   Linux - General (
-   -   Terminal Commands (find) (

syco__ 03-29-2011 01:45 AM

Terminal Commands (find)
Im having a few problems with the find command. IM rather new to linux so it could be very simple sorry to waste your time but all help would be great.

What i want to do is search a directory for files that are more then 500kb this is what i have come up with but it doesnt seem to be working very well.

find /usr/bin -exec {-size +500k};

im not real sure why its not working i think it has something to do with the exec command but i feel i need it from what i have read. If someone could explain it to me what i have done and what i need to do that would be great.

Thanks in advance.

Slackyman 03-29-2011 01:59 AM

Use simply

find /usr/bin -size +500k
You can use -exec if you want to manipulate each result of the find command and pass the results as argument to the specified command.
Silly example:

find /usr/bin -size +5000k -exec ls --color=yes {} \;

Telengard 03-29-2011 02:05 AM

You don't seem to be doing anything with the -exec option, so I don't understand why you think you need it.

The {} curly braces are probably being eaten by Bash because it uses them in a few different contexts. Again, I don't understand why you think you need them.

The following command will find all files in the current directory, and recurse all subdirectories, greater than 9K in size.


find -type f -size +9k
This command will do the same, but will not recurse subdirectories.


find -maxdepth 1 -type f -size +9k
This last command will show a long style listing of all selected files sorted by size.


find -maxdepth 1 -type f -size +9k -exec ls -hlS '{}' \;

All times are GMT -5. The time now is 12:46 AM.