Using regex in Mac OS X: why I have to add \ in {3, 5} ==> \{3, 5\} ...?
If I understand your question correctly, you do not need to escape the curly-braces with a backslash if you form the command properly.

In other words, when using a RegRx with grep, let it know the search pattern is a RegEx by using the -E option.

If you want an inverse match then use the -v option as well.

Example:

ls | grep -E -v '\.[A-Za-z]{0,5}$'



Note I used {0,5}$ instead of {3,5}$ to account for any extension up to 5 characters. If you want to include files that might have a 1 or 2 character extensions, then use {3,5}$ instead.


You can also use the following example:

ls | grep -E -v '\.[[:alpha:]]{0,5}$'


Sometimes a file extension can have numbers in them, so to account for that, use as an example:

ls | grep -E -v '\.[A-Za-z0-9]{0,5}$'


Or:

ls | grep -E -v '\.[[:alnum:]]{0,5}$'


Note: Some commands require the options to be passed individually, while others can be combined. In this case, grep does allow options to be concatenated. So in the example commands, -E -v can be expressed as -Ev or -vE, if you wish.