LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Syntax for ls with Ignore pattern? (https://www.linuxquestions.org/questions/linux-newbie-8/syntax-for-ls-with-ignore-pattern-4175431890/)

catalys 10-12-2012 02:08 PM

Syntax for ls with Ignore pattern?
 
I would like my ls command to exclude files ending with a particular extension, e.g. hoh, so that I do not have to pipe the result to a grep command.

Apparently this can be done with the -I (Ignore) option, but what is the correct syntax?

All these attempts failed (ALL the current folder files were listed):
ls -I[hoh$]
ls -I [hoh$]
ls -I/hoh$/
ls -I /hoh$/

(If only the "--help" function had examples...)

Thanks!

suicidaleggroll 10-12-2012 02:13 PM

Code:

ls -I '*hoh'

shivaa 10-12-2012 02:47 PM

You can achive this by using:
ls -la *.<extension>
For example, ls -la *.hoh


All times are GMT -5. The time now is 10:15 AM.