title: Bash: Check if a directory contains only files with a specific suffix
body: <p>I am trying to write a script that will check if a directory contains only
  a specific kind of file (and/or folder) and will return 1 for false, 0 for true.</p>
  <p>IE: I want to check if <code>/my/dir/</code> contains only <code>*.gz</code> files and nothing else.</p>
  <p>This is what i have so far, but it doesn't seem to be working as intended:</p>
  <pre><code># Basic vars
  readonly       THIS_JOB=${0##*/}
  readonly       ARGS_NBR=1
  
  
  declare        dir_in=$1
  
  
  dir_in=$1&quot;/*.gz&quot;
  #echo $dir_in
  
  files=$(shopt -s nullglob dotglob; echo ! $dir_in)
  echo $files
  
  if (( ${#files} ))
  then
      echo &quot;Success: Directory contains files.&quot;
      exit 0
  else
      echo &quot;Failure: Directory is empty (or does not exist or is a file)&quot;
      exit 1
  fi
  </code></pre>