bash - counting files, directories and subdirectories in a given path -
i trying figure how run simple script "count.sh" called path, e.g.:
count.sh /home/users/documents/myscripts
the script need iterate on directories in path , print how many files , folders (including hidden) in each level of path.
for example:
- 7
- 8
- 9
- 10
(myscripts - 7, documents - 8, users -9, home - 10)
and way, can run script using count.sh pwd
?
more or less that:
#!/bin/sh p="$1" while [ "/" != "$p" ]; echo "$p `find \"$p\" -maxdepth 1 -type f | wc -l`" p=`dirname "$p"`; done echo "$p `find \"$p\" -maxdepth 1 -type f | wc -l`"
you can use form current directory script.sh `pwd`
Comments
Post a Comment