The output is like that of du, so you get the recursive output of every subfolder.

# change /home to match the folder your interested in, change it to . for current folder (or remove the 'cd /home;' command)

# number of files & folders
(cd /home; IFS=$'\n'; for i in `find -type d`; do echo "`find $i | wc -l` $i"; done;)

# number of files
(cd /home; IFS=$'\n'; for i in `find -type d`; do echo "`find -type f $i | wc -l` $i"; done;)

# number of folders
(cd /home; IFS=$'\n'; for i in `find -type d`; do echo "`find -type d $i | wc -l` $i"; done;)

# number of links, sockets, etc.. change the "-type d" to whatever you want - look at "man find"

Output is:

# name

Where # is the number of files, folders, or both (or whatever you desginate -type TYPE to be)

Where name is the relative folder path (relative to where you cded to)

If you want the output to show you absolute path, then change that last $i to `readlink -f $i`

# change /home to match the folder your interested in, change it to . for current folder (or remove the 'cd /home;' command)

# number of files & folders
(cd /home; IFS=$'\n'; for i in `find -type d`; do echo "`find $i | wc -l` `readlink -f $i`"; done;)

# number of files
(cd /home; IFS=$'\n'; for i in `find -type d`; do echo "`find -type f $i | wc -l` `readlink -f $i`"; done;)

# number of folders
(cd /home; IFS=$'\n'; for i in `find -type d`; do echo "`find -type d $i | wc -l` `readlink -f $i`"; done;)

# number of links, sockets, etc.. change the "-type d" to whatever you want - look at "man find"

Copy-Paste-Ables:

# these are the same as above, except they dont have the cd. so they are designed to be run from current working dir & thus they are suitable for copy-pasting.

# number of files & folders (relative path in output)
(cd /home; IFS=$'\n'; for i in `find -type d`; do echo "`find $i | wc -l` $i"; done;)
# number of files (relative path in output)
(cd /home; IFS=$'\n'; for i in `find -type d`; do echo "`find -type f $i | wc -l` $i"; done;)
# number of folders (relative path in output)
(cd /home; IFS=$'\n'; for i in `find -type d`; do echo "`find -type d $i | wc -l` $i"; done;)

# number of files & folders (absolute path in output)
(cd /home; IFS=$'\n'; for i in `find -type d`; do echo "`find $i | wc -l` `readlink -f $i`"; done;)
# number of files (absolute path in output)
(cd /home; IFS=$'\n'; for i in `find -type d`; do echo "`find -type f $i | wc -l` `readlink -f $i`"; done;)
# number of folders (absolute path in output)
(cd /home; IFS=$'\n'; for i in `find -type d`; do echo "`find -type d $i | wc -l` `readlink -f $i`"; done;)

OUTPUT

Output example (relative path):

# (cd /var/log; IFS=$'\n'; for i in `find -type d`; do echo "`find $i | wc -l` $i"; done;)
187 .
2 ./mysql
3 ./fsck
2 ./ConsoleKit
2 ./unattended-upgrades
11 ./samba
3 ./samba/cores
1 ./samba/cores/nmbd
1 ./samba/cores/smbd
1 ./speech-dispatcher
2 ./hp
1 ./hp/tmp
6 ./mdm
3 ./apt
87 ./upstart
17 ./cups
1 ./sysstat
10 ./installer

Output example (absolute path):

# (cd /var/log; IFS=$'\n'; for i in `find -type d`; do echo "`find $i | wc -l` `readlink -f $i`"; done;)
187 /var/log
2 /var/log/mysql
3 /var/log/fsck
2 /var/log/ConsoleKit
2 /var/log/unattended-upgrades
11 /var/log/samba
3 /var/log/samba/cores
1 /var/log/samba/cores/nmbd
1 /var/log/samba/cores/smbd
1 /var/log/speech-dispatcher
2 /var/log/hp
1 /var/log/hp/tmp
6 /var/log/mdm
3 /var/log/apt
87 /var/log/upstart
17 /var/log/cups
1 /var/log/sysstat
10 /var/log/installer

The end.

 

Leave a Reply

Your email address will not be published. Required fields are marked *