Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
A directory is a file but its not a regular file, so the question is not clear enough
If he does not want directory, then something awfull like this should do:
echo $(($(ls -l | grep -v ^d | wc -l)-1))
That's the only way I would know to do it either, there must be a way of counting just files though. It'd be nice to get an output like: 13 files
4 directories
2 symbolic links
You could write a little script to do that cnm and post it up for us! :P
If they have the same extension you can count using:
ls *.txt | wc
You can use the diffcommand to compare two directories if you just want to ensure that it copied successfully.
Use the 'tree' command. If its not present in the system by default, I recommend installing it.
It outputs a beautiful tree structure showing the files and the directories and finally printing number of files and directories in a folder.
how to find number of files,subfolders in a file using command
I have taken clue from previous post & come up with simplest way
Finding number of files in a folder
find . -type f | wc -l
this means output of find comand (which is only files no directories)is sent to wc which counts number of lines i.e number of files
Finding number of subfolders in a folder
(1)find . -type d | wc -l
This will give number of subfolders+1 because current folder also gets included.Note that the folders inside subfolders are also included in count.
(2)If you want to see only number of folders in current folder then
find . -maxdepth 1 -type d | wc -l
Here output is numberof subfolders+1
NOTE:folders inside subfolders not considered.
If this information helps you please thank me by pressing thumbs up button.Happy hacking.
Last edited by sumeet inani; 10-28-2009 at 09:53 AM.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.