Wednesday, May 12, 2010

Number of files and folders in a Linux folder

Recently I transfered a folder with big a mount of archives and something seemed to be missing, obviously I wanted to verify that the amount of files was correct and probably just like you, I couldn't find a simple Linux command to help me with this, in fact I found crazy commands like:

"echo $(($(ls -l | grep -v ^d | wc -l)-1))"

Until I found the simple and elegant "tree", if you don't have it already just run a simple:

"sudo apt-get install tree"

And then you'll have the simple response you were looking for:

"234 directories, 1786 files"