Error with "ls" command - Mandriva

This is a discussion on Error with "ls" command - Mandriva ; Using 2008.1 When I run "ls *.ged" I get the following message ls: invalid option -- j It doesn't happen with plain ls, but does with "ls *". I have tried running /bin/ls, unalias ls, starting a new session and ...

+ Reply to Thread
Results 1 to 6 of 6

Thread: Error with "ls" command

  1. Error with "ls" command

    Using 2008.1

    When I run "ls *.ged" I get the following message

    ls: invalid option -- j

    It doesn't happen with plain ls, but does with "ls *".

    I have tried running /bin/ls, unalias ls, starting a new session and
    rebooting.

    As a workaround, I tried "ls | grep *.ged" That gives:

    grep: invalid option -- j

    This error is not new. There are references to it on Google. An answer on
    linuxquestions.org avoided the point altogether. Replies on other fora are
    over my head. It seems to have something to do with ASCII codes?

    Any guidance appreciated.

    Doug.
    --
    The Black Dog is walking, and this exercise is part of repairing the damage
    caused by an error in a program from Sourceforge. Giving up, for now.


  2. Re: Error with "ls" command

    Doug Laidlaw wrote:

    > Using 2008.1
    >
    > When I run "ls *.ged" I get the following message
    >
    > ls: invalid option -- j
    >
    > It doesn't happen with plain ls, but does with "ls *".
    >
    > I have tried running /bin/ls, unalias ls, starting a new session and
    > rebooting.
    >
    > As a workaround, I tried "ls | grep *.ged" That gives:
    >
    > grep: invalid option -- j
    >
    > This error is not new. There are references to it on Google. An answer
    > on
    > linuxquestions.org avoided the point altogether. Replies on other fora
    > are
    > over my head. It seems to have something to do with ASCII codes?
    >
    > Any guidance appreciated.
    >
    > Doug.
    > --
    > The Black Dog is walking, and this exercise is part of repairing the
    > damage
    > caused by an error in a program from Sourceforge. Giving up, for now.


    Further to the above, "ls -l" with no arguments works. "rm -f" with
    arguments, including wildcards, works. But ls with an argument won't.

    Doug.

  3. Re: Error with "ls" command

    On Wed, 30 Apr 2008 21:24:40 +1000, Doug Laidlaw wrote:
    > Using 2008.1
    >
    > When I run "ls *.ged" I get the following message
    >
    > ls: invalid option -- j
    >
    > It doesn't happen with plain ls, but does with "ls *".


    Happens because of a file name starting with a -

    See,
    cd tmp
    $ touch -- "-j"

    $ ls *
    ls: invalid option -- j

    $ ls -- *
    at_job.4226 -j

    gconfd-bittwister:
    lock

    Get rid of it, or rename it
    $ rm -- "-j"
    rm: remove regular empty file `-j'? y

  4. Re: Error with "ls" command

    Bit Twister wrote:

    > On Wed, 30 Apr 2008 21:24:40 +1000, Doug Laidlaw wrote:
    >> Using 2008.1
    >>
    >> When I run "ls *.ged" I get the following message
    >>
    >> ls: invalid option -- j
    >>
    >> It doesn't happen with plain ls, but does with "ls *".

    >
    > Happens because of a file name starting with a -
    >
    > See,
    > cd tmp
    > $ touch -- "-j"
    >
    > $ ls *
    > ls: invalid option -- j
    >
    > $ ls -- *
    > at_job.4226 -j
    >
    > gconfd-bittwister:
    > lock
    >
    > Get rid of it, or rename it
    > $ rm -- "-j"
    > rm: remove regular empty file `-j'? y


    I follow all that, but there ain't one!

    [doug@dougshost ~]$ ls -- "-j"
    ls: cannot access -j: No such file or directory
    [doug@dougshost ~]$ rm -- "-j"
    rm: cannot remove `-j': No such file or directory
    [doug@dougshost ~]$ ls -- "-*"
    ls: cannot access -*: No such file or directory
    [doug@dougshost ~]$ ls *
    ls: invalid option -- .
    Try `ls --help' for more information.
    [doug@dougshost ~]$ ls *.ged
    ls: invalid option -- j
    Try `ls --help' for more information.
    [doug@dougshost ~]$

    And "ls -- ." gives an "ls" of the current directory, as I would expect.

    (*Later - using Leafnode can be handy.)

    AHA!

    I seemed to recall reading in the Linux CookBook that I can use -- before
    a filename starting with a hyphen, without quotes. And I suspected that
    "-*" in quotes would be takeen literally, not expanded.

    "ls -- -*" gave: -bib.lyx -bib.tex -nojen.ged

    Solved! The two bib. files have been there for a while - with hyphens,
    I think, but I have never included them in a search term. I did create a
    file "nojen.ged," and must have hit the - key without noticing.

    Doug.


  5. Re: Error with "ls" command

    Doug Laidlaw writes:

    >Using 2008.1


    >When I run "ls *.ged" I get the following message


    >ls: invalid option -- j


    You apparently have some file that starts with -j or something like that
    Try
    ls -- *.ged
    or rename the rogue file

    echo "*.ged"
    will show you which file it is.


    >It doesn't happen with plain ls, but does with "ls *".


    >I have tried running /bin/ls, unalias ls, starting a new session and
    >rebooting.


    >As a workaround, I tried "ls | grep *.ged" That gives:


    >grep: invalid option -- j


    >This error is not new. There are references to it on Google. An answer on
    >linuxquestions.org avoided the point altogether. Replies on other fora are
    >over my head. It seems to have something to do with ASCII codes?


    Nope, just bad file naming.

    Look through the ls listings to see something which eitehr has -j at the
    beginning of a filename of a space and then -j in the middle of a file
    name.



    >Any guidance appreciated.
    >
    >Doug.
    >--
    >The Black Dog is walking, and this exercise is part of repairing the damage
    >caused by an error in a program from Sourceforge. Giving up, for now.



  6. Re: Error with "ls" command

    Thanks Bill. You were right. Full story in BitTwister's thread

    Doug.

    Unruh wrote:

    > Doug Laidlaw writes:
    >
    >>Using 2008.1

    >
    >>When I run "ls *.ged" I get the following message

    >
    >>ls: invalid option -- j

    >
    > You apparently have some file that starts with -j or something like that
    > Try
    > ls -- *.ged
    > or rename the rogue file
    >
    > echo "*.ged"
    > will show you which file it is.
    >
    >
    >>It doesn't happen with plain ls, but does with "ls *".

    >
    >>I have tried running /bin/ls, unalias ls, starting a new session and
    >>rebooting.

    >
    >>As a workaround, I tried "ls | grep *.ged" That gives:

    >
    >>grep: invalid option -- j

    >
    >>This error is not new. There are references to it on Google. An answer
    >>on
    >>linuxquestions.org avoided the point altogether. Replies on other fora
    >>are
    >>over my head. It seems to have something to do with ASCII codes?

    >
    > Nope, just bad file naming.
    >
    > Look through the ls listings to see something which eitehr has -j at the
    > beginning of a filename of a space and then -j in the middle of a file
    > name.
    >
    >
    >
    >>Any guidance appreciated.
    >>
    >>Doug.
    >>--
    >>The Black Dog is walking, and this exercise is part of repairing the
    >>damage
    >>caused by an error in a program from Sourceforge. Giving up, for now.



+ Reply to Thread