Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

How can you ls everything else the the files *{.tex, .aux}?

I run unsuccessfully

ls -I".tex"
share|improve this question

migrated from stackoverflow.com Aug 30 '09 at 19:18

This question came from our site for professional and enthusiast programmers.

Can someone s/else than/except for/g? –  las3rjock Aug 30 '09 at 19:21

5 Answers 5

up vote 9 down vote accepted
ls -I*.tex -I*.aux


ls --hide=*.tex --hide=*.aux
share|improve this answer

If you use bash and have the extglob shell option set (which is usually the case):

ls !(*.tex|*.aux)
share|improve this answer
This is the one. See this same question over at ServerFault: serverfault.com/questions/41783/… –  Telemachus Aug 30 '09 at 19:53
Or this question at Stack Overflow: stackoverflow.com/questions/670460/move-all-files-except-one Which is a question by the same user where I already gave the same answer... –  sth Aug 30 '09 at 20:21
@Sth: Well, you got two upvotes out of it from me at least. (I only remembered the thread on Serverfault, since I learned this trick there.) –  Telemachus Aug 30 '09 at 21:12

If you're using zsh with EXTENDED_GLOB option set:


where 'pattern' is what you want to match, except for anything matching 'negpattern'.


ls -d *~*.mp3

will list all the files in your cwd except those ending in '.mp3'.

If you're not using zsh, give it a try, this kind of intelligent expansion is everywhere.

share|improve this answer

you may use:

ls | grep -v *.tex | grep -v *.aux
share|improve this answer
I don't think that does what you think it does. grep takes regular expressions as parameters, not shell wildcards. Also, the shell will expand those wildcards first anyway. –  Greg Hewgill Aug 30 '09 at 19:22
"ls | grep -v .tex | grep -v .aux" seems to work. (On my machine, ls does not take the -I or --hide flags.) –  las3rjock Aug 30 '09 at 19:48
You could also use a regex with egrep: ls | egrep -v '(aux|tex)$' –  mtak Apr 4 at 6:48

@Greg it works but one looses the color coding of ls which at times is very helpful

ls --hide="?*.tex" --hide="?*.aux"

preserves the color coding too.

share|improve this answer
This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post - you can always comment on your own posts, and once you have sufficient reputation you will be able to comment on any post. –  50-3 Apr 4 at 7:12
i complemented the answer and pointed out the deficiency in a given solution. I don't think every post is supposed to be the exact answer to the question. beauty of the forum is that answers can also be discussed and remarked upon. still I modified my post with exact answer. i couldn't comment on Greg's post that's why I had to post it here –  comiventor Apr 4 at 7:21
Ire has made the same answer as this one. See the accepted answer of this thread. –  Masi Apr 5 at 5:52
It is similar but not same ... at times, only shell pattern works (i.e. using '?' to represent any character) . I faced problem and using '?' worked –  comiventor Apr 7 at 5:59

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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