开发者

Limits of length for the expansion of * in Bash? [duplicate]

开发者 https://www.devze.com 2023-03-14 20:41 出处:网络
This question already has answers here: Bash command line and input limit (4 answers) Closed 2 years ago.
This question already has answers here: Bash command line and input limit (4 answers) Closed 2 years ago.

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?


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/


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号