![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| list contents of directory | carl_vieyra | UNIX for Dummies Questions & Answers | 3 | 01-30-2007 03:24 PM |
| how to generate a random list from a given list | mskcc | Shell Programming and Scripting | 3 | 05-30-2006 03:30 AM |
| Creating file contents using contents of another file | ReV | Shell Programming and Scripting | 21 | 02-24-2006 10:25 AM |
| Message trying to list contents of directory | sallender | UNIX for Dummies Questions & Answers | 1 | 10-19-2005 08:22 AM |
| Comparing a distinct value in 1 list with another list | manualvin | Shell Programming and Scripting | 6 | 06-22-2004 06:42 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Hey guys!
I'm so glad I found this site, I've had so many questions and have been left alone for roughly a year scanning man pages but It's just not quite cutting it for some things. So, I often like to list directories when browsing around my local machine, a friend's machine, or my web server. Especially the latter where size, permissions, and extensions really matter. The problem is most of the commands I use just don't quite show all the information I need! If I use Code:
ls -lsh If I use Code:
du -sh * Both of these have the same problem: after reading the man pages up and down I can't figure out how to simply list the total number of files in a given directory! I hope these questions aren't ridiculous, I'd just like to see if there is a better way of doing this that other people know, I've held of on asking anyone until now to avoid all of the "RTFM" responses I'd get in IRC Channels. Thanks in advance! |
|
||||
|
Quote:
Code:
# ls -1 |wc -l Code:
# find /path -type f | wc -l |
|
||||
|
Cool, thanks! So you use ls to list it in separate it lines then pipe it to wc to count those lines and print the total number.
That seems like such a hassle, though, there is no flag or something like that so that du or ls can simply show the total number of files in its output? |
|
||||
|
Quote:
|
|
||||
It's not that tough, I've just always loved using the shell because you can do so much with so little text, I try to compact as much as I can in one line. This works well, and is just what I wanted, thanks so much!What about the differences between du and ls? Do most people use the latter even though it's not a very simple output? Are there better ways of doing it? I ask because I'm always surprised by little neat tricks and tips people have here and there. |
|
||||
|
man du, man ls
The former tells you about "disk usage", that is: how much space is used by a file or a part of a directory tree. The following method will tell you how much space is used by which part of the file hierarchy: cd to a directory issue "du -ks * | sort -rn" You will get a list of files/directories with their respective space used sorted reversely by size. If you find a directory in this list with an abnormal size, then change into it and repeat the command there to see which files/directory is responsible for that, and so forth. The latter command (ls) is to list directory information: my system (AIX) lacks the -h option you seem to find so useful, but it has ~20 other options to tailor the output to exactly your needs. Most of the times i use "ls -l" or "ls -lai", "ls -lrt" to get the files sorted by time and for everything else i look into the manpage for reference. Nobody knows all the options of "ls" by heart, it is for most of us a mixture of having a general grasp of what to use and a knowledge of where to find additional information when it is needed. Quote:
Quote:
If you think you need that set of info on a regular basis use "alias" and "function" to make it easier accessible, as ghostdog74 has already told you. bakunin |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|