Professional Web Applications Themes

ls *.txt gives "bash: /bin/ls: Argument list too long" !? - Linux / Unix Administration

In issuing the following command to BASH on RH 8.0 I receive the error "bash: /bin/ls: Argument list too long" What gives? Command issued was: ls *.txt Surely there's a way around this, but the man and info pages don't really have any information in this regard. Any help is always apprecaited, thanks, Rob...

  1. #1

    Default ls *.txt gives "bash: /bin/ls: Argument list too long" !?

    In issuing the following command to BASH on RH 8.0 I receive the error
    "bash: /bin/ls: Argument list too long" What gives?

    Command issued was:

    ls *.txt

    Surely there's a way around this, but the man and info pages don't
    really have any information in this regard. Any help is always
    apprecaited, thanks,

    Rob
    Rob Baxter Guest

  2. #2

    Default Re: ls *.txt gives "bash: /bin/ls: Argument list too long" !?

    On 14 Dec 2003 15:52:15 -0800, Rob Baxter wrote:
    > In issuing the following command to BASH on RH 8.0 I receive the error
    > "bash: /bin/ls: Argument list too long" What gives?
    >
    > Command issued was:
    >
    > ls *.txt
    >
    > Surely there's a way around this, but the man and info pages don't
    > really have any information in this regard. Any help is always
    > apprecaited, thanks,

    Today's Tip of the Day, very large
    Frequently Asked Questions (faq) Search engine:

    [url]http://groups.google.com/advanced_group_search[/url]
    Argument list too long in the first box
    *linux* in the Newsgroup, pick English

    Results 1 - 10 of about 5,080. Search took 2.02 seconds
    Bit Twister Guest

  3. #3

    Default Re: ls *.txt gives "bash: /bin/ls: Argument list too long" !?

    just do a 'find . -name "*.txt" -exec WHATEVER_COMMAND {} \;'

    That will show you all files, or just replace the exec with ls to just see
    the file names.


    "Rob Baxter" <rbaxtercyence.com> wrote in message
    news:baea5fa.0312141552.f389bb5posting.google.com ...
    > In issuing the following command to BASH on RH 8.0 I receive the error
    > "bash: /bin/ls: Argument list too long" What gives?
    >
    > Command issued was:
    >
    > ls *.txt
    >
    > Surely there's a way around this, but the man and info pages don't
    > really have any information in this regard. Any help is always
    > apprecaited, thanks,
    >
    > Rob

    Michael Hyman Guest

  4. #4

    Default Re: ls *.txt gives "bash: /bin/ls: Argument list too long" !?

    On 14 Dec 2003 15:52:15 -0800, Rob Baxter
    <rbaxtercyence.com> wrote:
    > In issuing the following command to BASH on RH 8.0 I receive the error
    > "bash: /bin/ls: Argument list too long" What gives?
    >
    > Command issued was:
    >
    > ls *.txt
    >
    > Surely there's a way around this, but the man and info pages don't
    > really have any information in this regard. Any help is always
    > apprecaited, thanks,
    >
    ls | grep '\.txt$'


    --
    Thanks to Nigeria, any email with the word "urgent" in the subject
    or address will be deleted.
    Bill Marcum Guest

  5. #5

    Default Re: ls *.txt gives "bash: /bin/ls: Argument list too long" !?

    On Sun, 14 Dec 2003 15:52:15 -0800, Rob Baxter wrote:
    > In issuing the following command to BASH on RH 8.0 I receive the error
    > "bash: /bin/ls: Argument list too long" What gives?
    >
    > Command issued was:
    >
    > ls *.txt
    >
    > Surely there's a way around this, but the man and info pages don't
    > really have any information in this regard. Any help is always
    > apprecaited, thanks,
    >
    > Rob
    Well thats interesting. Check the ls command first to see if it has been
    aliased to something odd. Type "alias" by itself and see if there is a
    listing for ls. Or just nuke any alias by typing "unalias ls". Then try
    the command.

    If no aliases exist you have found a bug. Type this:
    "sh --version"
    To get your version of bash. Mine is
    GNU bash, version 2.05b.0(1)-release (i686-pc-linux-gnu)

    Perhaps RedHat has an update for you?

    I hope something in this helps you.

    MS

    Michael Studer Guest

  6. #6

    Default Re: ls *.txt gives "bash: /bin/ls: Argument list too long" !?

    Michael Studer wrote:
    > On Sun, 14 Dec 2003 15:52:15 -0800, Rob Baxter wrote:
    >
    >>In issuing the following command to BASH on RH 8.0 I receive the error
    >>"bash: /bin/ls: Argument list too long" What gives?
    [...]
    > Well thats interesting. Check the ls command first to see if it has been
    > aliased to something odd. Type "alias" by itself and see if there is a
    > listing for ls. Or just nuke any alias by typing "unalias ls". Then try
    > the command.
    >
    > If no aliases exist you have found a bug.
    It's not a bug. It's expected behavior, and precisely what xargs(1) is
    meant to solve:

    find . -name \*.txt | xargs ls

    Cheers,
    M.

    Matias Atria Guest

  7. #7

    Default Re: ls *.txt gives "bash: /bin/ls: Argument list too long" !?

    On Tue, 16 Dec 2003 06:11:11 +0000, Matias Atria wrote:
    >
    > It's not a bug. It's expected behavior, and precisely what xargs(1) is
    > meant to solve:
    >
    > find . -name \*.txt | xargs ls
    >
    > Cheers,
    > M.
    Oh really? Hmm then I must have a bug on my system.
    > ls *.txt
    junk.txt junk1.txt junk2.txt

    MS
    Michael Studer Guest

  8. #8

    Default Re: ls *.txt gives "bash: /bin/ls: Argument list too long" !?

    Michael Studer wrote:
    > On Tue, 16 Dec 2003 06:11:11 +0000, Matias Atria wrote:
    >
    >>It's not a bug. It's expected behavior, and precisely what xargs(1) is
    >>meant to solve:
    >>
    >> find . -name \*.txt | xargs ls
    >>
    >>Cheers,
    >>M.
    >
    >
    > Oh really? Hmm then I must have a bug on my system.
    >
    >
    >>ls *.txt
    >
    > junk.txt junk1.txt junk2.txt
    >
    > MS
    The original poster has a lot of .txt files and *.txt when expanded is
    too long a string to fit in the command line buffer which has a finite
    length. The find / xargs combination is a known way of dealing with
    this situation.

    So in that respect, it IS expected behaviour.

    Except I never expect it when it happens to me :-)

    Cheers

    JK

    John Kelly Guest

  9. #9

    Default Re: ls *.txt gives "bash: /bin/ls: Argument list too long" !?

    Rob Baxter wrote:
    > In issuing the following command to BASH on RH 8.0 I receive the error
    > "bash: /bin/ls: Argument list too long" What gives?
    Your shell is performing pathname expandsion on "*.txt" and the result
    is too big for the command line buffer. This is a common problem
    > Command issued was:
    >
    > ls *.txt
    It doesn't matter, any command fed *.txt unquoted(') will exhibit the
    same problem.
    > Surely there's a way around this,
    Many ways, for example:
    ls | grep '\.txt$'
    find -name "*.txt" | xargs ls
    su root then ls *.txt
    > but the man and info pages don't
    > really have any information in this regard.
    You are right, the correct place for this is ...
    man bash /pathname expansion
    man xargs
    but the man pages on RH8.0 are poor in this regard.


    Ian Wilson Guest

  10. Moderated Post

    Default Re: ls *.txt gives "bash: /bin/ls: Argument list too long" !?

    Removed by Administrator
    Doug Freyburger Guest
    Moderated Post

  11. #11

    Default Re: ls *.txt gives "bash: /bin/ls: Argument list too long" !?

    On Wed, 17 Dec 2003 at 16:30 GMT, Doug Freyburger wrote:
    > Michael Studer wrote:
    >> Matias Atria wrote:
    >>
    >> > It's not a bug. It's expected behavior
    >
    > Because the buffers built into shells are of finite size.
    It may be, but it's is more likely to be the underlying system; a
    command that works on one system may fail on another. For example,
    I created 9999 files ending with .x. On Linux, FreeBSD and SunOS, I
    could do "echo *.x" successfully with bash and ksh (and Bourne sh
    on SunOS), since echo is a built-in command.

    /home/aa276/tmp $ echo *.x
    0.x 1.x 10.x 100.x 1000.x 1001.x 1002.x 1003.x 1004.x 1005.x 1006.x
    ......
    9994.x 9995.x 9996.x 9997.x 9998.x

    On SunOS and Linux I could also successfully do "ls *.x", but on
    FreeBSD:

    $ ls *.x
    -bash: /bin/ls: Argument list too long

    --
    Chris F.A. Johnson [url]http://cfaj.freeshell.org[/url]
    ================================================== =================
    My code (if any) in this post is copyright 2003, Chris F.A. Johnson
    and may be copied under the terms of the GNU General Public License
    Chris F.A. Johnson Guest

  12. #12

    Default Re: ls *.txt gives "bash: /bin/ls: Argument list too long" !?

    Doug Freyburger wrote:
    >>Matias Atria wrote:
    >>
    >>>It's not a bug. It's expected behavior
    >
    > Because the buffers built into shells are of finite size.
    It's not a shell limitation, but one of the underlying OS.
    Bash has no size limit for lists, other than the amount of
    memory. The problem is when you pass an extremely long list
    to the execve() system call (or equivalent), which does
    have fixed size limits. That's where the OP's error message
    came from. See the execve(2) man page, section "ERRORS",
    description of E2BIG.

    Cheers,
    M.

    Matias Atria Guest

  13. #13

    Default Re: ls *.txt gives "bash: /bin/ls: Argument list too long" !?

    Ian Wilson wrote:
    >> Surely there's a way around this,
    >
    > Many ways, for example:
    > ls | grep '\.txt$'
    > find -name "*.txt" | xargs ls
    > su root then ls *.txt
    In what platform does this work for root? Definitely none
    that I know of.

    Cheers,
    M.

    Matias Atria Guest

  14. #14

    Default Re: ls *.txt gives "bash: /bin/ls: Argument list too long" !?

    Matias Atria wrote:
    > Doug Freyburger wrote:
    > > Matias Atria wrote:
    >
    > > >It's not a bug. It's expected behavior
    >
    > > Because the buffers built into shells are of finite size.
    >
    > It's not a shell limitation, but one of the underlying OS.
    > Bash has no size limit for lists, other than the amount of
    > memory. The problem is when you pass an extremely long list
    > to the execve() system call (or equivalent), which does
    > have fixed size limits. That's where the OP's error message
    > came from. See the execve(2) man page, section "ERRORS",
    > description of E2BIG.
    It is both. bash may not have limited buffers but other shells
    do. That is why the point where the error occurs is different
    in different cases. Does the shell have a fixed buffer? How big
    is that buffer on this version of Unix from this vendor at this
    patch level? What is the limit on the exec* calls? What is the
    virtual memory limit? Answer all of these questions, pick the
    smallest number, and that's when the failure starts.

    Of course answering all of those questions is too much work. It
    is much easier to expect "a lot" of filenames and switch to xargs.
    Use experience to build judgement about what "a lot" means.
    Doug Freyburger Guest

  15. #15

    Default Re: ls *.txt gives "bash: /bin/ls: Argument list too long" !?

    Matias Atria wrote:
    > Ian Wilson wrote:
    >
    >>> Surely there's a way around this,
    >>
    >>
    >> Many ways, for example:
    >> ls | grep '\.txt$'
    >> find -name "*.txt" | xargs ls
    >> su root then ls *.txt
    >
    >
    > In what platform does this work for root? Definitely none
    > that I know of.
    SCO OSR5

    Ian Wilson Guest

  16. #16

    Default Re: ls *.txt gives "bash: /bin/ls: Argument list too long" !?

    Ian Wilson wrote:
    > Matias Atria wrote:
    >
    >> Ian Wilson wrote:
    >>
    >>>> Surely there's a way around this,
    >>>
    >>>
    >>>
    >>> Many ways, for example:
    >>> ls | grep '\.txt$'
    >>> find -name "*.txt" | xargs ls
    >>> su root then ls *.txt
    >>
    >>
    >>
    >> In what platform does this work for root? Definitely none
    >> that I know of.
    >
    >
    > SCO OSR5
    >


    % uname -srv
    SCO_SV 3.2 5.0.7
    % ls * | wc
    Arguments too long.
    0 0 0
    % su -c 'ls * | wc'
    Password:
    3430 3423 41773

    Although now I look into it its merely a csh vs sh issue so su'ing is
    uneccessary. I've watched a colleague using su to get round this limit
    for years and that stuck in my head. I use ksh by preference so didn't
    hit this problem myself.

    % ksh 'ls * | wc'
    3430 3423 41773

    Ian Wilson Guest

  17. #17

    Default Re: ls *.txt gives "bash: /bin/ls: Argument list too long" !?

    [email]dfreybur[/email] (Doug Freyburger) wrote:
    > Matias Atria wrote:
    > > It's not a shell limitation, but one of the underlying OS.
    > It is both. bash may not have limited buffers but other shells
    > do.
    True, but the OP is using bash on RH 8.0. That's what I had in mind.

    Cheers,
    M.
    Matias Atria Guest

Similar Threads

  1. grep argument list too long...how to get around it?
    By Steve Grazzini in forum PERL Beginners
    Replies: 9
    Last Post: November 1st, 10:05 PM
  2. cfqueryparam ignores null="yes" when list="yes"
    By Matt W. in forum Coldfusion Database Access
    Replies: 1
    Last Post: April 22nd, 07:51 PM
  3. Replies: 12
    Last Post: November 28th, 09:51 AM
  4. Replies: 0
    Last Post: July 21st, 03:13 PM
  5. "Start" "Program" "Menu" list is empty
    By Pete in forum Windows XP/2000/ME
    Replies: 2
    Last Post: July 10th, 10:42 PM

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
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139