4
rated 0 times
[
4]
[
0]
/ answers: 1 / hits: 1852
/ 2 Years ago, thu, june 23, 2022, 8:19:35
Source: Any directory tree with any number and type of files. Q: How many .jpg
or .jpg
and .png
(for example) are in each subdirectory?
How can I limit the code below for files with 1 or more specific extension(s)? Having trouble inserting the -type f -name "*.jpg*"
, for example.
for DIR in $(find . -maxdepth 99 -type d)
do
printf "%10d %s
" $(find ${DIR}|wc -l) "${DIR}"
done
Desired output:
118 ./aaa
73 ./aaa/bbb
16 ./aaa/bbb/ccc
If more than one file types are counted, then their combined total number in each subdirectories should be displayed.
More From » command-line