Created
December 5, 2013 16:47
-
-
Save HenokT/7808936 to your computer and use it in GitHub Desktop.
Bash extended glob support
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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