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

I run unsuccessfully

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

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

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

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

4 Answers

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

or

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

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

ls !(*.tex|*.aux)
link|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
feedback

If you're using zsh with EXTENDED_GLOB option set:

pattern~negpattern

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

Example:

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.

link|improve this answer
feedback

you may use:

ls | grep -v *.tex | grep -v *.aux
link|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
feedback

Your Answer

 
or
required, but never shown

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