Results 1 to 5 of 5

Thread: ls -Rd is broken

  1. #1
    Join Date
    Aug 2021
    Location
    Carson City, Nv
    Beans
    84
    Distro
    Ubuntu 22.04 Jammy Jellyfish

    ls -Rd is broken

    Hi Folks,


    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 /
    /
    I believe I have stumbled on a bug in ls.

    --glenn

  2. #2
    Join Date
    Feb 2015
    Beans
    Hidden!
    Distro
    Xubuntu 22.04 Jammy Jellyfish

    Re: ls -Rd is broken

    I'm not so sure it is a bug. Just by reading the man file descriptions you posted the recursive switch lists subdirectories recursively. Now the "-d" switch lists only the directory and not its content. Question is; is a subdirectory considered "content" of a directory? If a subdirectory is considered as content within a directory I would expect the results you post.

    Question: Have you ever seen that combination of options used elsewhere outside of Ubuntu with a different result?

    I'm no expert and am not even entirely sure of the answer here, but from my usage of Linux/Ubuntu over the past 14 years I would not expect any other result than the one you got from my reading of those 2 option descriptions you posted. I suspect the 2 options you are combining there are not compatible with each other.

    I'd suggest you wait for further replies from more experienced/qualified users and just take this post as "something to consider" in the meantime.

    Cheers, yeti

  3. #3
    Join Date
    Aug 2021
    Location
    Carson City, Nv
    Beans
    84
    Distro
    Ubuntu 22.04 Jammy Jellyfish

    Re: ls -Rd is broken

    It turns out that d eliminates R. This is designed behavior. Too bad, R would be useful in searching for a directory.

    hanks,
    --glenn

  4. #4
    Join Date
    May 2006
    Location
    Switzerland
    Beans
    2,907
    Distro
    Ubuntu 20.04 Focal Fossa

    Re: ls -Rd is broken

    Quote Originally Posted by psychohermit View Post
    Too bad, R would be useful in searching for a directory.
    There are other commands you could use for that.

    "tree":

    Could be that the "tree" package is not installed by default. To install it:
    Code:
    sudo apt install tree
    Example of using it:
    Code:
    > cd /var/lib/apt
    > tree -d
    
    .
    ├── lists
    │** ├── auxfiles
    │** └── partial
    ├── mirrors
    │** └── partial
    └── periodic
    
    6 directories

    "find":

    Code:
    > cd /var/lib/apt
    > find . -type d -print
    
    .
    ./periodic
    ./lists
    ./lists/auxfiles
    ./lists/partial
    ./mirrors
    ./mirrors/partial

  5. #5
    Join Date
    Aug 2021
    Location
    Carson City, Nv
    Beans
    84
    Distro
    Ubuntu 22.04 Jammy Jellyfish

    Re: ls -Rd is broken

    Good solutions to searching for a directory. Thanks,
    --glenn

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •