ls command refuses to give just folder names per command line switch

Florian Diesch diesch at spamfence.net
Sat Nov 28 21:09:18 UTC 2009


Nils Kassube <kassube at gmx.net> writes:

> Ray Parrish wrote:
>> I have been trying to figure out why ls will not return folder names
>> only as per the man page's insistence that it will with the -d
>>  switch. Here is output from Terminal
>> 
>> ray at RaysComputer:~/links$ ls --directory
>> .
>> ray at RaysComputer:~/links$
>> 
>> No sub folders returned from the ls command.
>
> I think that's OK. What you asked ls to do is list the current directory 
> but only the directory, not the contents. And the current folder is ".". 
> If you want to list the directories within the current directory you 
> could use
>
> ls -d */
>
> instead.
>
>> What I'm trying to get ultimately is a recursive list of all files of
>>  a certain type in all sub folders of the current folder, including
>>  the current folder. But when I add the --recursive command, and
>>  include a *.html on the end, all I get is a list of the .html files
>>  in the current folder, and none from any of the sub folders.
>
> Then use the find command. What you want is something like this:
>
> find -type f -name \*.html

At least in 9.10 Bash supports **/*.html to match recursively all .html
files - at least until the maximum command line length isn't reached.



   Florian
-- 
<http://www.florian-diesch.de/software/shell-scripts/>




More information about the ubuntu-users mailing list