4

This question already has an answer here:

I want to list all the files with .sh extension and size greater than 5kb with the same directory. what I know is how to list all files with a specific size by:

find . -size +5k -exec ls -l {} \+

and how to list all the files with specific extension by:

ls *.sh

what do I need to know is how to do both simultaneously?

marked as duplicate by muru bash Mar 8 '18 at 0:33

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

9

find has a -name option to perform a test on the file name, e.g. to list every file with an .sh extension:

find -type f -name "*.sh"

Use -iname instead if you want it to be case-insensitive, e.g. also find .Sh or .SH. You can simply combine this with -size:

find -type f -name "*.sh" -size +5k

find also has an -ls option to display file stats, while your -exec approach is totally OK it may be faster and is much easier to type:

find -type f -name "*.sh" -size +5k -ls

Not the answer you're looking for? Browse other questions tagged or ask your own question.