LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (http://www.linuxquestions.org/questions/linux-general-1/)
-   -   Terminal Commands (find) (http://www.linuxquestions.org/questions/linux-general-1/terminal-commands-find-871621/)

syco__ 03-29-2011 12: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 12:59 AM

Use simply
Code:

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:
Code:

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

Telengard 03-29-2011 01: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.

Code:

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

Code:

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

Code:

find -maxdepth 1 -type f -size +9k -exec ls -hlS '{}' \;
:study: http://www.linuxcommand.org/man_pages/find1.html


All times are GMT -5. The time now is 04:52 AM.