5

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
  • 692
  • 1
  • 7
  • 24

2 Answers2

6

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

shopt -s nullglob
dirs=( */ )
anubhava
  • 713,503
  • 59
  • 514
  • 593
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
  • 83,326
  • 15
  • 202
  • 231