Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
5 of 6 added 85 characters in body
ls */

This would list the contents of all the non-hidden subdirectories in the current directory. Since you only seem to have subdirectories with numeric names, this will show the contents of these.

The shell globbing pattern * would expand to all non-hidden names in the current directory. Adding a / at the end of the pattern forces the pattern to expand to only directories (since non-directories can't have / in their names).

With the zsh shell, the following filename globbing pattern would expand to only regular files in each subdirectory

*/*(.)

To do something with those names that matches, you would loop over the expansion of that glob pattern:

for pathname in */*(.); do
    # use "$pathname" here
done

In bash or sh, you would call a small script from find instead:

find . -mindepth 2 -maxdepth 2 -type f -exec sh '
    for pathname do
        # use "$pathname" here
    done' sh {} +

But that's really just a fancy way of writing

for pathname in */*; do
    [ ! -f "$pathname" ] && continue
    # use "$pathname" here
done

except that the find variation would skip symbolic links to regular files and include hidden names (set the dotglob shell option in bash to include these).

Again, this would do what you wanted (look in directories with numeric names) because you appear to only have subdirectories with numeric names.

Assuming that there may be other subdirectories too,

for pathname in */*; do
    [ ! -f "$pathname" ] && continue
    case $(dirname "$pathname") in
        *[!0-9]*) continue
    esac
    # use "$pathname" here
done

or, with bash,

for pathname in */*; do
    if [ ! -f "$pathname" ] ||
       [[ $(dirname "$pathname") == *[!0-9]* ]]
    then
        continue
    fi
    # use "$pathname" here
done

These loops would loop over all the names in the subdirectories, but would skip any name not referring to a regular file (or a symbolic link to one), and would also skip any file in a subdirectory whose name contains anything that is not a digit.

With the extglob shell option in bash, you could make that a bit shorter:

shopt -s exglob
for pathname in +([0-9])/*
    [ ! -f "$pathname" ] && continue
    # use "$pathname" here
done

The pattern +([0-9)/ would expand to names of directories that only have digits in their names. This would also work in zsh if the KSH_GLOB option was set instead of extglob.