How do I mask out files with a particular extension when using ls

How do I mask out files with a particular extension when using ls.


ie


ls "mask out .cmd"


Thanks

MacBook Pro with Retina display, OS X El Capitan (10.11.1), null

Posted on Sep 2, 2016 11:01 PM

Reply
4 replies

Sep 3, 2016 3:11 AM in response to Xorron

You enable/disable extglob in the Bash shell. Type the blue content in the Terminal.


# enable extglob

$ shopt -s extglob

# show all files except those with .cmd extension. The '!' is a negation operator here.

$ ls !(*.cmd)

# disable extglob

$ shopt -u extglob


For more information on extglob, and additional operators, see man bash(1), and then search for extglob. Also, read this stackoverflow post on usage and other extglob operators.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

How do I mask out files with a particular extension when using ls

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.