7

In Bash

echo *

is almost equivalent to ls.

You can do things like

echo */*-out/*.html > all-my-html-files-on-one-line

Since * is a command line argument then there should be a limit on the length.

What is that limit?

Is the limit different between echo the Bash command and /bin/echo the program?

Ulrich Eckhardt
  • 16,572
  • 3
  • 28
  • 55
Aleksandr Levchuk
  • 3,751
  • 4
  • 35
  • 47

2 Answers2

9

The shell does not limit this

You can see the limit for your system with (run on my 64bit linux:)

$ getconf ARG_MAX
2097152

See this very informational page http://www.in-ulm.de/~mascheck/various/argmax/

codeforester
  • 39,467
  • 16
  • 112
  • 140
sehe
  • 374,641
  • 47
  • 450
  • 633
3

I believe the command line limit is the value of ARG_MAX which you can see with

getconf ARG_MAX

This is not a bash variable, which would suggest that the limit is the same for echo in bash and /bin/echo.

borrible
  • 17,120
  • 7
  • 53
  • 75
  • 7
    `echo` doesn't execute any external commands, so it's not affected by ARG_MAX. Try it out `/bin/echo $(seq $(getconf ARG_MAX))` will fail but `echo $(seq $(getconf ARG_MAX))` will probably succeed. – Piotr Praszmo Jun 23 '11 at 22:35