• weird problem with ls comman

    From Woozy Song@[email protected] to alt.os.linux on Sat Mar 7 20:39:27 2026
    From Newsgroup: alt.os.linux

    in Downloads directory, I can type something like
    ls -rtl *pdf
    works as expected, but if I try
    ls -rtl *html
    or
    dir *html
    I get this error:

    ls: invalid option -- 'y'
    Try 'ls --help' for more information.
    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From J.O. Aho@[email protected] to alt.os.linux on Sat Mar 7 15:32:22 2026
    From Newsgroup: alt.os.linux

    On 07/03/2026 13.39, Woozy Song wrote:
    in Downloads directory, I can type something like
    ls -rtl *pdf
    works as expected, but if I try
    ls -rtl *html
    or
    dir *html
    I get this error:

    ls: invalid option -- 'y'
    Try 'ls --help' for more information.

    I would guess you have a file which name begins with '-y'

    you could try: find ~/Downloads -name "*html"
    or you can: ls ~/Downloads | grep html$
    --
    //Aho
    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From Lew Pitcher@[email protected] to alt.os.linux on Sat Mar 7 16:31:09 2026
    From Newsgroup: alt.os.linux

    On Sat, 07 Mar 2026 15:32:22 +0100, J.O. Aho wrote:

    On 07/03/2026 13.39, Woozy Song wrote:
    in Downloads directory, I can type something like
    ls -rtl *pdf
    works as expected, but if I try
    ls -rtl *html
    or
    dir *html
    I get this error:

    ls: invalid option -- 'y'
    Try 'ls --help' for more information.

    I would guess you have a file which name begins with '-y'

    you could try: find ~/Downloads -name "*html"
    or you can: ls ~/Downloads | grep html$

    or
    ls -- *html
    (but programs aren't obliged to recognize the '--' option
    and POSIX doesn't mandate it for ls(1), so check before using)


    or
    ls ./*html
    (which /does/ satisfy the POSIX requirements, and avoids
    argument flag parsing by prefixing the filename expansion
    values with a relative path based in the current directory)
    --
    Lew Pitcher
    "In Skills We Trust"
    Not LLM output - I'm just like this.
    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From Lew Pitcher@[email protected] to alt.os.linux on Sat Mar 7 16:35:09 2026
    From Newsgroup: alt.os.linux

    On Sat, 07 Mar 2026 16:31:09 +0000, Lew Pitcher wrote:

    On Sat, 07 Mar 2026 15:32:22 +0100, J.O. Aho wrote:

    On 07/03/2026 13.39, Woozy Song wrote:
    in Downloads directory, I can type something like
    ls -rtl *pdf
    works as expected, but if I try
    ls -rtl *html
    or
    dir *html
    I get this error:

    ls: invalid option -- 'y'
    Try 'ls --help' for more information.

    I would guess you have a file which name begins with '-y'

    you could try: find ~/Downloads -name "*html"
    or you can: ls ~/Downloads | grep html$

    or
    ls -- *html
    (but programs aren't obliged to recognize the '--' option
    and POSIX doesn't mandate it for ls(1), so check before using)

    Oops, correction:
    POSIX mandates that ls(1) "shall conform to XBD Utility Syntax
    Guidelines", and Guideline 10 of those guidelines says that
    "The first -- argument that is not an option-argument should
    be accepted as a delimiter indicating the end of options."
    So, I stand corrected in my caveat.

    or
    ls ./*html
    (which /does/ satisfy the POSIX requirements, and avoids
    argument flag parsing by prefixing the filename expansion
    values with a relative path based in the current directory)
    --
    Lew Pitcher
    "In Skills We Trust"
    Not LLM output - I'm just like this.
    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From rbowman@[email protected] to alt.os.linux on Sat Mar 7 20:35:33 2026
    From Newsgroup: alt.os.linux

    On Sat, 7 Mar 2026 20:39:27 +0800, Woozy Song wrote:

    in Downloads directory, I can type something like ls -rtl *pdf works as expected, but if I try ls -rtl *html or dir *html I get this error:

    ls: invalid option -- 'y'
    Try 'ls --help' for more information.

    Both forms work for me and find two html files.
    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From Lawrence =?iso-8859-13?q?D=FFOliveiro?=@[email protected] to alt.os.linux on Sat Mar 7 22:34:48 2026
    From Newsgroup: alt.os.linux

    On Sat, 7 Mar 2026 20:39:27 +0800, Woozy Song wrote:

    in Downloads directory, I can type something like
    ls -rtl *pdf
    works as expected, but if I try
    ls -rtl *html
    or
    dir *html
    I get this error:

    ls: invalid option -- 'y'
    Try 'ls --help' for more information.

    Try

    ls -rtl -- *html
    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From Lawrence =?iso-8859-13?q?D=FFOliveiro?=@[email protected] to alt.os.linux on Sat Mar 7 22:35:46 2026
    From Newsgroup: alt.os.linux

    On Sat, 7 Mar 2026 16:31:09 -0000 (UTC), Lew Pitcher wrote:

    (but programs aren't obliged to recognize the '--' option
    and POSIX doesn't mandate it for ls(1), so check before using)

    GNU supports it, and that’s all that matters. ;)
    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From Woozy Song@[email protected] to alt.os.linux on Sun Mar 8 09:41:33 2026
    From Newsgroup: alt.os.linux

    Lew Pitcher wrote:
    On Sat, 07 Mar 2026 15:32:22 +0100, J.O. Aho wrote:

    On 07/03/2026 13.39, Woozy Song wrote:
    in Downloads directory, I can type something like
    ls -rtl *pdf
    works as expected, but if I try
    ls -rtl *html
    or
    dir *html
    I get this error:

    ls: invalid option -- 'y'
    Try 'ls --help' for more information.

    I would guess you have a file which name begins with '-y'

    you could try: find ~/Downloads -name "*html"
    or you can: ls ~/Downloads | grep html$

    or
    ls -- *html
    (but programs aren't obliged to recognize the '--' option
    and POSIX doesn't mandate it for ls(1), so check before using)


    or
    ls ./*html
    (which /does/ satisfy the POSIX requirements, and avoids
    argument flag parsing by prefixing the filename expansion
    values with a relative path based in the current directory)


    but I am typing single hyphen not two
    This is under Debian, bash version 5.2.37
    ls version 9.7
    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From Lew Pitcher@[email protected] to alt.os.linux on Sun Mar 8 04:02:15 2026
    From Newsgroup: alt.os.linux

    On Sun, 08 Mar 2026 09:41:33 +0800, Woozy Song wrote:

    Lew Pitcher wrote:
    On Sat, 07 Mar 2026 15:32:22 +0100, J.O. Aho wrote:

    On 07/03/2026 13.39, Woozy Song wrote:
    in Downloads directory, I can type something like
    ls -rtl *pdf
    works as expected, but if I try
    ls -rtl *html
    or
    dir *html
    I get this error:

    ls: invalid option -- 'y'
    Try 'ls --help' for more information.

    I would guess you have a file which name begins with '-y'

    you could try: find ~/Downloads -name "*html"
    or you can: ls ~/Downloads | grep html$

    or
    ls -- *html
    (but programs aren't obliged to recognize the '--' option
    and POSIX doesn't mandate it for ls(1), so check before using)


    or
    ls ./*html
    (which /does/ satisfy the POSIX requirements, and avoids
    argument flag parsing by prefixing the filename expansion
    values with a relative path based in the current directory)


    but I am typing single hyphen not two
    This is under Debian, bash version 5.2.37
    ls version 9.7

    As others have already pointed out, you have a file that
    matches the *html glob, and starts with "-y". Something
    like
    -you.html
    or
    -yhtml

    Now, file globbing is done by the shell, before it invokes
    the named program, so the shell expands your
    ls -rtl *html
    into something like
    ls -rtl -you.html
    and ls sees the leading -y of the first filename as an
    invalid flag argument.

    With
    ls -rtl -- *html
    the shell will still expand the command by file globbing,
    but now into
    ls -rtl -- -you.html
    and ls sees the -- flag, and processes the arguments
    following it as filenames

    With
    ls -rtl ./*html
    the shell will still expand the command by file globbing,
    but now into
    ls -rtl ./you.html
    and ls does /not/ see any flagged arguments after the -rtl,
    and processes everything that follows as filenames

    Does that answer the question?
    --
    Lew Pitcher
    "In Skills We Trust"
    Not LLM output - I'm just like this.
    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From R.Wieser@[email protected] to alt.os.linux on Tue Mar 10 21:26:28 2026
    From Newsgroup: alt.os.linux

    Woozy,

    but I am typing single hyphen not two

    We already know that what you are doing doesn't work, you do not have to
    tell us again.

    Have you alreadt tried one of the several suggestions to help you pin-point
    / show you where the problem is located ? If not, why ?

    Pick one of the suggestions, follow it *to the letter* and post the
    result(s).

    Regards,
    Rudy Wieser


    --- Synchronet 3.21d-Linux NewsLink 1.2