Here's how one might list all files matching a pattern in bash:
ls *.jar
How to list the complement of a pattern? i.e. all files not matching *.jar?
You can do it with grep alone (without find). grep -riL "foo" . -L, --files-without-match each file processed. -R, -r, --recursive Recursively search subdirectories listed.
Wildcards allow you to specify succinctly a pattern that matches a set of filenames (for example, *. pdf to get a list of all the PDF files). Wildcards are also often referred to as glob patterns (or when using them, as "globbing").
Use egrep-style extended pattern matching.
ls !(*.jar)
This is available starting with bash-2.02-alpha1. Must first be enabled with
shopt -s extglob
As of bash-4.1-alpha there is a config option to enable this by default.
ls | grep -v '\.jar$'
for instance.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With