Pages

Thursday, June 1, 2017

How to Count Number of Files and Subdirectories inside a Given Directory

The easiest way to count number of files and subdirectories in a directory using a tree command, which is best known for displaying files and directories in tree-like form.
Although you can always enable quotas to restrict disk space and inode usage to avoid user abuse, this command may be useful anyway. By default, the current working directory is assumed if no arguments are given:
$ tree -iLf 1
Sample Output
.
./10-Top-Linux-Distributions-of-2015.png
./adobe-flash-player-alternative.jpg
./CentOS-7-Security-Hardening-Guide.png
./coding.png
./d-logo-sketch.png
./Experts-Share-Thoughts-on-25th-Anniversary-of-the-World-Wide-Web-431806-2.jpg
./Get-Default-OS-Logo.png
./InstallCinnamonDesktoponUbuntuandFedora720x345.png
./Install-Nagios-in-CentOS.jpg
./Install-Vmware-Workstation-12-in-Linux.png
./Install-WordPress-on-CentOS-Fedora.png
./Linux-Essentials-Bundle-Course.png
./Linux-Online-Training-Courses.png
./Linux-PDF-Readers-Viewers-Tools.png
./linux-play-game.jpg
./logo.png
./nrpe-3.0.tar.gz
./Python-and-Linux-Administration-Course.png
./Ravi
./teamviewer 11 0 57095 i386
./Telegram
./tsetup.0.10.1.tar.xz
./VBoxGuestAdditions_5.0.0.iso
./Vivaldi-About.png
./VMware-Workstation-Full-12.1.1-3770994.x86_64.bundle
3 directories, 22 files
If you want to view the same information for /var/log, do:
$ tree -iLf 1 /var/log
Sample Output
/var/log
/var/log/alternatives.log
/var/log/apt
/var/log/aptitude
/var/log/auth.log
/var/log/boot.log
/var/log/bootstrap.log
/var/log/btmp
/var/log/btmp.1
/var/log/ConsoleKit
/var/log/cups
/var/log/dmesg
/var/log/dpkg.log
/var/log/faillog
/var/log/fontconfig.log
/var/log/fsck
/var/log/gpu-manager.log
/var/log/hp
/var/log/installer
/var/log/kern.log
/var/log/lastlog
/var/log/mdm
/var/log/mintsystem.log
/var/log/mintsystem.timestamps
/var/log/ntpstats
/var/log/samba
/var/log/speech-dispatcher
/var/log/syslog
/var/log/syslog.1
/var/log/teamviewer11
/var/log/unattended-upgrades
/var/log/upstart
/var/log/vbox-install.log
/var/log/wtmp
/var/log/wtmp.1
/var/log/Xorg.0.log
/var/log/Xorg.0.log.old
13 directories, 23 files
Type the command below to view information about files and subdirectories in the directory ISOs.

      ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
                                                    ► Read more: http://adf.ly/1n5YMD
      ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬

No comments:

Post a Comment