I have a directory that contains a bunch of .zip files as well as their unpacked version. I need to get a list of all the directory's and ignore the .zip files. How can I do this?
I am thinking of using grep
and ls
, but am not sure how to put it together.
Get a list of all sub-directories and store it into an array:
shopt -s nullglob
dirs=( */ )
If you can turn on extglob
like so:
shopt -s extglob
declare -a files=( !(*.zip) )
See more about bash pattern matching on the Pattern Matching man page.
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