[PLUG] Print list of folders

Pete Lancashire pete at petelancashire.com
Sat Dec 12 18:31:41 UTC 2015


Want: I wish to print a list of directories (but not the files or
subdirectories
contained in the directories)

The short answer

find <from the directory you want to start from>  -mindepth 1 -maxdepth 1
-type d


the find program is your friend, but one you will love and hate at the same
time, even I have to still do
a man or info find.

find <directory from where you want to start> [<search options>] [<print
options>]

Your first requirement 'only directories' is handled by the option -type
<objecttype>, in your case object
type is d for directory

Let use /usr as the starting point

find /usr -type d

This will output all directories under /usr and /usr it self since it is a
directory

Next you only want the directories under your starting point, find calls
this depth, but it is not the
depth option you want (see find can be hard to get to like at times)

the option you want is maxdepth, in your case you want a maximum depth of 1.

find /usr -maxdepth 1 -type d

Note the maxdepth is before the type, I'll leave it up you to find out why

You said only the directories under the one your interested in, so you will
need to use mindepth as well.

so ...

find /usr -mindepth 1 -maxdepth 1 -type d

Hope this is what you are looking for ....

-pete


On Sat, Dec 12, 2015 at 10:08 AM, John Jason Jordan <johnxj at comcast.net>
wrote:

> Thanks for the additional suggestions - so many options! However, the
> initial suggestion to send the output of ls to a simple text file did
> the job. The only thing that might have made it a bit more elegant
> would have been to concatenate another command to send the text file to
> the printer with lpr. But it was just about as fast for me to double
> click on the text file, which opened it in Gedit, and then Ctrl-p to
> open the print dialog box.
>
> This was a one-off situation which I will likely never need to do
> again.
> _______________________________________________
> PLUG mailing list
> PLUG at lists.pdxlinux.org
> http://lists.pdxlinux.org/mailman/listinfo/plug
>



More information about the PLUG mailing list