[plug] directory listing

Jonathan Young jonathan at pcphix.com
Mon Apr 10 13:55:15 WST 2006


On 4/10/2006, "Alex Nordstrom" <lx at se.linux.org> wrote:

>Monday, 10 April 2006 13:29, Jon Miller wrote:
>> After looking up the parameters for the ls command I still cannot
>> find what I'm looking for which is a simple listing of all
>> subdirectories starting at a certain point. I want a listing of
>> subdirectories only in a directory called /shared. I've issue the
>> following command ls -d and yieldednothing.
>
>Ah, I remember this from a first-year tutorial at Curtin.
>
>Try:
>
>ls -d /shared/*/
>
>What -d does is to just list all matching files (including directories). 
>If you didn't have it, ls would also proceed to list the contents of 
>any matching directories. The slash at the end will make sure only 
>directories are matched.
>
>For a long listing, try:
>
>ls -l | grep ^d
>
>Where ^d matches entries with 'd' (for directory) as the first character 
>on a line.

Both very useful.  How do you get a list of files sizes as well?

I.e., if I start in /etc and type ls -l I get lots of useful information
and can see the size of certain files.  If I want to know how much space
required to backup /etc/* including sub-directories, how do I get the
bottom line figures?

In DOS it would be

dir /a/s

with /a showing hidden files
and /s including sib-directories

As the listing goes past it includes sub-totals for each directory and
then a total at the end.  I have never managed to get Bash to do this...

- Jonathan



More information about the plug mailing list