Skip to content

Instantly share code, notes, and snippets.

@thefotes
Created April 14, 2015 14:45
Show Gist options
  • Save thefotes/ea7d3ab93686c1af34c7 to your computer and use it in GitHub Desktop.
Save thefotes/ea7d3ab93686c1af34c7 to your computer and use it in GitHub Desktop.
Counts number of files in each subdirectory of the current directory
#!/bin/bash
set -e
for d in */; do
count=$(find $d -type f | wc -l)
if [[ $count -eq 1 ]]; then
result="$d $count"
echo $result >> results.txt
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment