6

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.

farid99
  • 712
  • 2
  • 7
  • 25

2 Answers2

6

Get a list of all sub-directories and store it into an array:

shopt -s nullglob
dirs=( */ )
anubhava
  • 761,203
  • 64
  • 569
  • 643
5

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.

Jeff Bowman
  • 90,959
  • 16
  • 217
  • 251