Re: [PLUG] ls -d does not work as it should
On 06/25/2018 05:08 PM, Michael Rasmussen wrote: > On 2018-06-25 16:18, Steve Christiansen wrote: >> On 6/25/2018 3:52 PM, Rich Shepard wrote: >> >>> According to 'man ls' the -d option should 'list directories >>> themselves, not their >>> contents'. But, here it doesn't work. For example from within ~/: >>> >>> $ ls -d >>> ./ >>> >>> $ ls --directory >>> ./ >>> >>> I doubt this is a Slackware issue and I'm curious why it might not be >>> working as expected. Has anyone else run into this issue? >>> >>> Rich >>> ___ >>> PLUG mailing list >>> PLUG@pdxlinux.org >>> http://lists.pdxlinux.org/mailman/listinfo/plug >>> >> >> Rich, >> It's working as expected. >> "ls" with no arguments lists the contents of the current directory. >> "ls -d" with no other arguments lists the current directory, not its >> contents, which is of course "." > > To expand that on that correct response, > > try ls -d */ > > for an edited example: > michael$ ls -d */ > Documents > Downloads > Finance > Pictures > ... > > > Rich, Indeed, another unfortunate example of bad documentation grammar. programmers are historically poor at this. "list directories themselves, not their contents" talks about the directory you are in, not the directories _below_ the one you are in (i.e. contents). So I would write the description as "list the current directory, not its contents" "ls -l" assumes "ls -l ." so "ls -d" assumes ls -d ." ls [OPTION]... [FILE]... the [FILE] is not really optional! We tend to forget about "." and ".." As per Michael above, if you what the directory "contents" of where you are: ls -d * # assumes "./*" ls -d */ # assumes "./*" ls -d $PWD # expanded "." ls -d $PWD/* 0r ls -d /* -Ed signature.asc Description: OpenPGP digital signature ___ PLUG mailing list PLUG@pdxlinux.org http://lists.pdxlinux.org/mailman/listinfo/plug
Re: [PLUG] ls -d does not work as it should
Wow .. so many responses ... I also feel that I should express my outrage about your daring "ls does not do what it should". Pretty confident statement! Well, the problem is that ./ is the directory you are trying to list in your example. There is also ../ present. These dot names are important for traversing the directory tree back. Without them life would be much more difficult and also significantly slower. Git is popular example how painful it can be if you can trace ownership/relationship one way only. Linus is my hero, but this seems to be some oversight. Tomas On Mon, Jun 25, 2018, 5:41 PM Rich Shepard wrote: > On Mon, 25 Jun 2018, Brian Stanaland wrote: > > > I don't understand why this works but... > > > > ls -d */ > > Brian, > >Okay ... that's another interesting solution. > > Thanks, > > Rich > ___ > PLUG mailing list > PLUG@pdxlinux.org > http://lists.pdxlinux.org/mailman/listinfo/plug > ___ PLUG mailing list PLUG@pdxlinux.org http://lists.pdxlinux.org/mailman/listinfo/plug
Re: [PLUG] ls -d does not work as it should
On Mon, 25 Jun 2018, Brian Stanaland wrote: I don't understand why this works but... ls -d */ Brian, Okay ... that's another interesting solution. Thanks, Rich ___ PLUG mailing list PLUG@pdxlinux.org http://lists.pdxlinux.org/mailman/listinfo/plug
Re: [PLUG] ls -d does not work as it should
On Mon, 25 Jun 2018, John Meissen wrote: I generally take the easy way and just do ls -l | grep drw You could do find . -type d -maxdepth 1 Or if you want it sorted, find . -type d -maxdepth 1 | sort Each has it's own quirks. Thanks, John. Rich ___ PLUG mailing list PLUG@pdxlinux.org http://lists.pdxlinux.org/mailman/listinfo/plug
Re: [PLUG] ls -d does not work as it should
On 2018-06-25 16:18, Steve Christiansen wrote: On 6/25/2018 3:52 PM, Rich Shepard wrote: According to 'man ls' the -d option should 'list directories themselves, not their contents'. But, here it doesn't work. For example from within ~/: $ ls -d ./ $ ls --directory ./ I doubt this is a Slackware issue and I'm curious why it might not be working as expected. Has anyone else run into this issue? Rich ___ PLUG mailing list PLUG@pdxlinux.org http://lists.pdxlinux.org/mailman/listinfo/plug Rich, It's working as expected. "ls" with no arguments lists the contents of the current directory. "ls -d" with no other arguments lists the current directory, not its contents, which is of course "." To expand that on that correct response, try ls -d */ for an edited example: michael$ ls -d */ Documents Downloads Finance Pictures ... -- Michael Rasmussen, Portland Oregon Be Appropriate && Follow Your Curiosity ___ PLUG mailing list PLUG@pdxlinux.org http://lists.pdxlinux.org/mailman/listinfo/plug
Re: [PLUG] ls -d does not work as it should
On 6/25/2018 4:38 PM, Brian Stanaland wrote: I don't understand why this works but... ls -d */ [root@li1233-197 log]# ls -d */ anaconda/ audit/ chrony/ httpd/ rhsm/ sa/ tuned/ Brian Brilliant! It works because of shell globbing. Compare to echo */ Steve On Mon, Jun 25, 2018 at 7:34 PM, John Meissen wrote: rshep...@appl-ecosys.com said: What option would you use to list only subdirectories and not files in the cwd or the subdirectories? I generally take the easy way and just do ls -l | grep drw You could do find . -type d -maxdepth 1 Or if you want it sorted, find . -type d -maxdepth 1 | sort Each has it's own quirks. ___ PLUG mailing list PLUG@pdxlinux.org http://lists.pdxlinux.org/mailman/listinfo/plug ___ PLUG mailing list PLUG@pdxlinux.org http://lists.pdxlinux.org/mailman/listinfo/plug
Re: [PLUG] ls -d does not work as it should
On 6/25/2018 4:22 PM, Rich Shepard wrote: Steve, I interpreted the man page as using the -d option to list only subdirectories of the cwd. Why would ls have an option to tell you you're in the current working directory? I agree that -d by itself is next to useless, but it's helpful with wildcards. To list the names of files and directories beginning with, say, the letter "a" ls -d a* The -d prevents the command from listing directories' contents instead of their names. What option would you use to list only subdirectories and not files in the cwd or the subdirectories? I don't know if ls will do that without some kind of filter. I usually do something like find * -type d -prune The -prune prevents recursion all the way down the directory tree. Rich ___ PLUG mailing list PLUG@pdxlinux.org http://lists.pdxlinux.org/mailman/listinfo/plug ___ PLUG mailing list PLUG@pdxlinux.org http://lists.pdxlinux.org/mailman/listinfo/plug
Re: [PLUG] ls -d does not work as it should
I don't understand why this works but... ls -d */ [root@li1233-197 log]# ls -d */ anaconda/ audit/ chrony/ httpd/ rhsm/ sa/ tuned/ Brian On Mon, Jun 25, 2018 at 7:34 PM, John Meissen wrote: > > rshep...@appl-ecosys.com said: > >What option would you use to list only subdirectories and not files > in the > > cwd or the subdirectories? > > I generally take the easy way and just do > ls -l | grep drw > > You could do > find . -type d -maxdepth 1 > > Or if you want it sorted, > find . -type d -maxdepth 1 | sort > > Each has it's own quirks. > > > > ___ > PLUG mailing list > PLUG@pdxlinux.org > http://lists.pdxlinux.org/mailman/listinfo/plug > -- "Anyone who has never made a mistake has never tried anything new." -Albert Einstein ___ PLUG mailing list PLUG@pdxlinux.org http://lists.pdxlinux.org/mailman/listinfo/plug
Re: [PLUG] ls -d does not work as it should
My memory may be failing me. I'm pretty sure I used '-d' to get a listing of all entries in the cwd that are marked as directories. So if I $(mkdir foo bar baz) and then use 'ls -d' I expect to see "./ ./foo ./bar ./baz". On Mon, Jun 25, 2018 at 4:18 PM, Steve Christiansen wrote: > On 6/25/2018 3:52 PM, Rich Shepard wrote: > > According to 'man ls' the -d option should 'list directories themselves, >> not their >> contents'. But, here it doesn't work. For example from within ~/: >> >> $ ls -d >> ./ >> >> $ ls --directory >> ./ >> >> I doubt this is a Slackware issue and I'm curious why it might not be >> working as expected. Has anyone else run into this issue? >> >> Rich >> ___ >> PLUG mailing list >> PLUG@pdxlinux.org >> http://lists.pdxlinux.org/mailman/listinfo/plug >> >> > Rich, > It's working as expected. > "ls" with no arguments lists the contents of the current directory. > "ls -d" with no other arguments lists the current directory, not its > contents, which is of course "." > > Steve > > > ___ > PLUG mailing list > PLUG@pdxlinux.org > http://lists.pdxlinux.org/mailman/listinfo/plug > ___ PLUG mailing list PLUG@pdxlinux.org http://lists.pdxlinux.org/mailman/listinfo/plug
Re: [PLUG] ls -d does not work as it should
On Mon, 25 Jun 2018, Steve Christiansen wrote: It's working as expected. "ls" with no arguments lists the contents of the current directory. "ls -d" with no other arguments lists the current directory, not its contents, which is of course "." Steve, I interpreted the man page as using the -d option to list only subdirectories of the cwd. Why would ls have an option to tell you you're in the current working directory? What option would you use to list only subdirectories and not files in the cwd or the subdirectories? Rich ___ PLUG mailing list PLUG@pdxlinux.org http://lists.pdxlinux.org/mailman/listinfo/plug
Re: [PLUG] ls -d does not work as it should
On Mon, 25 Jun 2018, Dick Steffens wrote: Results on UbuntuMATE 16.04: rsteff@ENU-2:~$ ls -d . rsteff@ENU-2:~$ Huh! I'm glad to see I'm not the only one missing the expected results. Is there a mail list where this deficiency can be pointed out to the appropriate developer(s)? Thanks, Dick, Rich ___ PLUG mailing list PLUG@pdxlinux.org http://lists.pdxlinux.org/mailman/listinfo/plug
Re: [PLUG] ls -d does not work as it should
On 6/25/2018 3:52 PM, Rich Shepard wrote: According to 'man ls' the -d option should 'list directories themselves, not their contents'. But, here it doesn't work. For example from within ~/: $ ls -d ./ $ ls --directory ./ I doubt this is a Slackware issue and I'm curious why it might not be working as expected. Has anyone else run into this issue? Rich ___ PLUG mailing list PLUG@pdxlinux.org http://lists.pdxlinux.org/mailman/listinfo/plug Rich, It's working as expected. "ls" with no arguments lists the contents of the current directory. "ls -d" with no other arguments lists the current directory, not its contents, which is of course "." Steve ___ PLUG mailing list PLUG@pdxlinux.org http://lists.pdxlinux.org/mailman/listinfo/plug
Re: [PLUG] ls -d does not work as it should
On 06/25/2018 03:52 PM, Rich Shepard wrote: According to 'man ls' the -d option should 'list directories themselves, not their contents'. But, here it doesn't work. For example from within ~/: $ ls -d ./ $ ls --directory ./ I doubt this is a Slackware issue and I'm curious why it might not be working as expected. Has anyone else run into this issue? Results on UbuntuMATE 16.04: rsteff@ENU-2:~$ ls -d . rsteff@ENU-2:~$ -- Regards, Dick Steffens ___ PLUG mailing list PLUG@pdxlinux.org http://lists.pdxlinux.org/mailman/listinfo/plug
[PLUG] ls -d does not work as it should
According to 'man ls' the -d option should 'list directories themselves, not their contents'. But, here it doesn't work. For example from within ~/: $ ls -d ./ $ ls --directory ./ I doubt this is a Slackware issue and I'm curious why it might not be working as expected. Has anyone else run into this issue? Rich ___ PLUG mailing list PLUG@pdxlinux.org http://lists.pdxlinux.org/mailman/listinfo/plug