List total number of directories
Hi!
Could someone tell me how to list the total number of directories I would have for instance in my home directory? Thank you in advance |
Code:
find -type d | wc -l |
Terve ToniT!
Thank you for your quick reply. I have tried find -type d | wc -l and got the number 11 but when I do a ls -F to verify how many directories I have, I only see two directories. How it comes that the command find -type d | wc -l gives me 11 ? Regards |
Oups! sorry I didn't notice the subdirectories. So I have not 2 directories but 12 and when I do the command find -type d | wc -l the output is 13. So it's counting also the directory I am currently in. Is there a way to ignore this directory ?
Regards |
Code:
find -type d | wc -l | awk '{print $1-1}' You can try those commands separatedly.
You might want to also try commands Code:
man find Code:
man wc Code:
man awk Also typing Code:
info coreutils is available to the shell. |
Thanks a lot ToniT!
That was a great and well explained tutorial ! it’s uncredible how powerful shell commands can be. |
All times are GMT -5. The time now is 08:35 PM. |