I forgot (still having my morning caffine) I forgot to have find strip off
the starting directory


so onto the printf options, another one with a zillon options

the entity you only want is the 'filename'  (I didn't write the man page),
what they really mean
is 'what entity find finds'.

In this case you want to print out '%f' and and newline

so the corrected command is

find /usr -maxdepth 1 -mindepth 1 -type d -printf '%f\n'

oh ....


>   Yet, 'ls -d */' is simpler still for listing all directories in the current
directory.

The problem with this is it adds a trailing slash to the name of the
directory, if one wants to
do something with the output you'll need to get rid of the slash



On Sat, Dec 12, 2015 at 10:31 AM, Pete Lancashire <p...@petelancashire.com>
wrote:

> 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 <joh...@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@lists.pdxlinux.org
>> http://lists.pdxlinux.org/mailman/listinfo/plug
>>
>
>
_______________________________________________
PLUG mailing list
PLUG@lists.pdxlinux.org
http://lists.pdxlinux.org/mailman/listinfo/plug

Reply via email to