-
All replies
-
Helpful answers
-
Sep 3, 2016 3:11 AM in response to Xorronby VikingOSX,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.
-
Sep 3, 2016 3:49 AM in response to Xorronby BobHarris,A very common method used by many Unix users is
ls | grep -v '\.cmd$'
This can be expanded to
ls | grep -v '\.cmd$' | grep -v '\.fred$' | grep -v '\.another$' | etc...
or
ls | egrep -v '\.cmd$|\.fred$|\.george$|\.charlie$|\.paul$'
-
Sep 3, 2016 5:05 AM in response to Xorronby Mark Jalbert,In bash as VikingOSX points out ( note: added the d option to ls):
shopt -s extglob
ls -d !(*.cmd)
In ksh without having to turn on anything:
ls -d !(*.cmd)
In zsh there is different syntax:
ls -d *~*.cmd
In tcsh again different syntax:
ls -d ^*.cmd
-
Sep 3, 2016 5:17 AM in response to Mark Jalbertby VikingOSX,Mark,
Thanks for adding the -d switch to avoid recursive descent into directories.