What is the command for getting a filename with any character EXCEPT a few?
Say I do not want the filename to contain the letters q and Q
ls [^qQ] does not work. What would I do?
If you want to use globbing (it's not always a good idea), you can use:
For this to work you must have
A better approach would be to use find, as you'll be able to
This will find all files (
If you have a huge number of files, find is better and faster than Bash's globbing, and won't overflow the maximal number of arguments.
Hope this helps!
If bash extended globbing is enabled, then you can invert matches with !(pattern) e.g. if
You can check the current value of the extglob option using
Why not simply
If instead of single characters you want to exclude file names containing certain strings of charaters you could do so with
i.e. separating any string with the escaped pipe char