Get number of files or directory using tree

Leave a comment
System Administration

Tree is an useful linux command to display a tree representation a full directory structure or a part of it.

On a Debian based distro like Ubuntu install:

sudo apt-get install tree

The last line of tree print a line like this:

346 directories, 174 files

If you’re changing files and directories and you want a real-time update of files and directories number, you can use watch.

watch -n 20 'tree | tail -n 1'

Tree will print the tree, tail will extract the last line, then watch will refresh the result every 20 seconds.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s