#!/bin/sh cas_subdirs=( btih btmh ) dirs=() for s in ${cas_subdirs[@]}; do if [ -d "cas/$s" ]; then dirs+=("cas/$s") fi done find "${dirs[@]}" -mindepth 2 -maxdepth 2 | LC_ALL=C sort | gzip >cas.names.txt.gz