Tuesday, October 18, 2016

How to show number of directories and files from command line


When working on the command line, sometimes you feel like need an information about how many directories and files is on certain location, it will be very handy if we can get such a information right on the command line itself.

Luckily, there is a tool that can help us with this problem, a command line program called 'tree' can show number of directories and files inside a directory of the given path. On lubuntu 'tree' does not come pre-installed, so we need to install first.

To install 'tree', simply run this command: 
sudo apt-get install tree

Once installed, to show information about how many directories and files on the current location, run 'tree' like this:
tree -iLf 1

You can also specify the location, like this:
tree -iLf 1 /home/kernelpanic/Documents
tree -iLf 1 /var/tmp
tree -iLf 1 ~/Pictures
tree -iLf 1 /bin/


No comments:

Post a Comment