Skip to content

Instantly share code, notes, and snippets.

@HenokT
Created December 5, 2013 16:47
Show Gist options
  • Save HenokT/7808936 to your computer and use it in GitHub Desktop.
Save HenokT/7808936 to your computer and use it in GitHub Desktop.
Bash extended glob support
In addition to the traditional globs (supported by all Bourne-family shells), Bash (and Korn Shell) offer extended globs, which have the expressive power of regular expressions. Korn shell enables this by default; in Bash, you can enable it using a command:
> shopt -s extglob
and disbale it using:
> shopt -u extglob
Example:
Suppose I want to list maven generated jars for all sub-projects from the root project folder but I want to exclude *javadoc.jar and *sources.jar files. This can be done as follows:
> ls -l */target/!(*javadoc|*sources).jar
Output:
root-project/sub-project-1/target/sub-project-1-<version>.jar
root-project/sub-project-1/target/sub-project-2-<version>.jar
root-project/sub-project-1/target/sub-project-3-<version>.jar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment