With that many files using flags with ls becomes a problem.
However you can usually use ls itself.
Counts can be gotten with the wc command. "wc -l" shows number of lines. (Type "man wc" for more details of the command.)
Count of files irrespective of department ID is simple:
Count of department IDs and their files becomes a bit more problematical but you can do it with a loop:
Code:
for DEPID in $(ls -R |awk -F\- '{print $1}' |sort -u)
do DEPCNT=$(ls ${DEPID}-* |wc -l)
echo Department ID $DEPID has $DEPCNT files
done
Putting it all together in one script:
Code:
#!/bin/bash
echo Total files is" $(ls |wc -l)
echo Break down by Department ID follows:
for DEPID in $(ls -R |awk -F\- '{print $1}' |sort -u)
do DEPCNT=$(ls ${DEPID}-* |wc -l)
echo Department ID $DEPID has $DEPCNT files
done