Re: the "ls" command line

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Aug 24, 2016 at 08:42:31AM +0300, Angelo Moreschini wrote:
> OK
> 
> Thank you, I   got  a good explanation...
> 
> But it is something that I yet don't understand:
> 
> The command (...) is composed both with
> 
> <*options* (-ld)>
>                and with
> <*argument* "/*" or "/*/">
> 
> In my acknowledge, both the arguments of these commands ( "/*" or "/*/")
> refer to the *content of a directory*, and the -ld option should have to
> select only the subdirectories.
> 
> Instead I get different output with "/*" or "/*/".
> 
> What happen really ?

You misunderstood the "d" options.  It does NOT list only directories.
Instead, IF an argument is a directory it list the directory, not the
files in the directory.

  $ ls /etc      # lists what is in /etc
  $ ls -d /etc   # list /etc, not its contents

Jon
> 
> 
> On Wed, Aug 24, 2016 at 12:25 AM, <cs@xxxxxxxxxx> wrote:
> 
> > On 23Aug2016 18:00, Markus Schönhaber <fedora-users@xxxxxxxxxxxxxxxxxxxxx>
> > wrote:
> >
> >> what is the difference between these two commands  ?
> >>> ls   /*
> >>>       and
> >>> ls  /*/
> >>>
> >>> -------------------
> >>> these two commands give me different output:
> >>>
> >>> ls -ld /*   =--->list all the files inside the directory (both files and
> >>> subdirectories)
> >>>
> >>> ls -ld /*/   =---> give me the list of only the (subdirectory inside the
> >>> directory)
> >>>
> >>
> >> The difference is not caused by ls but rather by the way the shell does
> >> the filename expansion.
> >>
> >
> > In case it isn't clear, only directories will have stuff inside them
> > (/a/b...) so /*/ will only match directries.
> >
> > BTW: If you're using bash, it will by default show you the expanded list
> >> of filenames that match the pattern if you press Ctrl-X * when the
> >> cursor is positioned directly after the pattern.
> >>
> >
> > And in any shell you can investigate this kind of thing like this:
> >
> >  echo /*
> >  echo /*/
> >
> > and see exactly what command is dipatched like this:
> >
> >  ( set -x ; ls /* )
> >  ( set -x ; ls /*/ )
> >
> > Using a subshell here purely so that the "set -x" applies only to the only
> > command.
> >
> > Cheers,
> > Cameron Simpson <cs@xxxxxxxxxx>
> >
> > --
> > users mailing list
> > users@xxxxxxxxxxxxxxxxxxxxxxx
> > To unsubscribe or change subscription options:
> > https://lists.fedoraproject.org/admin/lists/users@xxxxxxxxxxxxxxxxxxxxxxx
> > Fedora Code of Conduct: http://fedoraproject.org/code-of-conduct
> > Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
> > Have a question? Ask away: http://ask.fedoraproject.org
> >

> --
> users mailing list
> users@xxxxxxxxxxxxxxxxxxxxxxx
> To unsubscribe or change subscription options:
> https://lists.fedoraproject.org/admin/lists/users@xxxxxxxxxxxxxxxxxxxxxxx
> Fedora Code of Conduct: http://fedoraproject.org/code-of-conduct
> Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
> Have a question? Ask away: http://ask.fedoraproject.org

>>> End of included message <<<

-- 
Jon H. LaBadie                  jonfu@xxxxxxxxxx
--
users mailing list
users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe or change subscription options:
https://lists.fedoraproject.org/admin/lists/users@xxxxxxxxxxxxxxxxxxxxxxx
Fedora Code of Conduct: http://fedoraproject.org/code-of-conduct
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
Have a question? Ask away: http://ask.fedoraproject.org



[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [EPEL Devel]     [Fedora Magazine]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Desktop]     [Fedora Fonts]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Fedora Sparc]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux