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:

  1. 7
  2. 8
  3. 9
  4. 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

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -