Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Running ubuntu 20.04.2.0 LTS amd64 on a 7 year old HP ENVY TouchScreen Notebook.
From the ls man page.
Code:
-d, --directory
list directories themselves, not their contents
-R, --recursive
list subdirectories recursively
glenn@Psycho:~/Desktop$ ls -Rd /
/
glenn@Psycho:~/Desktop$ ls -dR /
/
This piqued my curiosity, so I just tested this. The command ls -R works independently, but there does appear to be an issue with ls -d, though my results differed slightly from OP's:
Code:
$ ls --directory
.
$ ls -d
.
This was on Mageia v. 8.
Update:
From the man page:
Quote:
-d, --directory
list directories themselves, not their contents
-d
Do not follow symbolic links named as operands unless the -H or -L options are specified. Do not treat directories differently than other types of files. The use of -d with -R or -f produces unspecified results.
IMO it would be more sensible for -R to be honoured, but the problem with "unspecified" things is that it becomes a matter of opinion as to what the correct thing to do is. One could even make the argument that it should operate like a find . -type d
In most cases you're probably better off just using 'find' anyway.
IMO it would be more sensible for -R to be honoured,
From my side I do not expect that. ls -ld <something> is used to list that something and nothing else. [again from my side] -R and -d are conflicting. From the other hand in recursive mode (-R) the -d flag is just pointless (or what should that mean?).
I think it essentially boils down to whether one thinks that '-d' should only apply to the command arguments, or the items that it recurses onto when -R is used.
Lots of ways at looking at this, which is why I wish they'd actually specified one.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.