-1

I have one directory with 48 sub-directories such like:

output$ ll
total 0
drwxr-sr-x+ 1 xxx 576 Apr 27 16:39 ./
drwxrws---+ 1 xxx 254 May  4 15:12 ../
drwxrws---+ 1 xxx  28 Apr 19 16:31 404904/
drwxrws---+ 1 xxx  28 Apr 19 16:31 404905/
drwxrws---+ 1 xxx  28 Apr 19 16:31 405003/
drwxrws---+ 1 xxx  28 Apr 19 16:31 405050/
drwxrws---+ 1 xxx  28 Apr 19 16:31 405077/
...

I wanted to write a bash for loop to work on some common analysis in them such like:

for d in {404904,404905,405503,...};
do
    echo $d
done

My question is how to loop these sub-directories instead of manually type in.

David Z
  • 6,641
  • 11
  • 50
  • 101

1 Answers1

1
for d in */; do
  echo "${d%/}"
done
Charles Duffy
  • 280,126
  • 43
  • 390
  • 441