Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then 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.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I'm looking for a command with a certain output. I've searched high and low for two days. Maybe you can help me.
I would like to list the total number of files including subdirectories and total amount of space the files are taking up. To be specific as in /var/ftp/pub/mp3. As in windows when you right-click on the folder and click properties. Or for command line, a command in Linux equal to Windows' "dir/w/s". I would like that info. Any ideas would be great. Thanks...
Distribution: openSUSE, Raspbian, Slackware. Previous: MacOS, Red Hat, Coherent, Consensys SVR4.2, Tru64, Solaris
Posts: 2,818
Rep:
Re: Command to list total number of files.
Quote:
Originally posted by WillieB_72 [snip]
I would like to list the total number of files including subdirectories and total amount of space the files are taking up. To be specific as in /var/ftp/pub/mp3. As in windows when you right-click on the folder and click properties. Or for command line, a command in Linux equal to Windows' "dir/w/s". I would like that info. Any ideas would be great.
[snip]
What about:
find . | wc -l ; du -sk .
which: finds all the files under the current directory (.) and pipes the output to wc which counts the number of lines (files). The subsequent du command gives a summary, in 1K blocks, of all the space in use under the current directory. Wrapping this in a bit of shell script would give it a prettier output:
Thanks a lot for the reply. I have been playing with that command and it's really close to what I want but I can't seem to get the output the same as dir/w/s. See below and maybe that will help.
*******************************
On Windows Box:
C:\Server\mp3s>dir/w/s
Volume in drive C has no label.
Volume Serial Number is 1094-4F2B
Any idea on how I could get the same data on Linux as in Windows above? The most important info to me is the # of files and directories, preferably seperate. Thanks again for your reply..:-)
-WillieB
CCNA/CCAI, CCNP
Cable ISP Admin
Last edited by WillieB_72; 01-28-2003 at 12:22 PM.
The only thing I can think of right now to account for the difference in the number of reported directories is that the `find' command may be counting some hidden files and/or directories that DOS isn't. The difference in the number of bytes (519316 * 1024 = 531779584) is undoubtedly due to du counting whole blocks whereas DIR is returning only the actual number of bytes in the files. Remember that you can ``fill'' up a disk with a relatively small number of 1-byte files since the filesystem allocates 4096 or 8192 (or whatever the cluster size is) bytes to a file at a time. Try:
echo "a" > a.file
ls -l a.file
du -sk a.file
du -sb a.file
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.