13

I'm generating models in Ruby on Rails, and some of these tables have an awful lot of columns. What's maximum length of a command in Mac OS X?

Chealion
  • 5,733
  • 28
  • 29
DGM
  • 287
  • 1
  • 3
  • 11

2 Answers2

20

The limit is not in bash but in your operating system. It's defined by the value of ARG_MAX in your OS's limits.h. You can get the value by running getconf ARG_MAX. On my OSX 10.5 machine (and most other BSD systems) it's 262144. You can read more about this limit here.

Kamil Kisiel
  • 12,184
  • 7
  • 48
  • 69
  • 1
    On Solaris 10, it is 1048320 - both are so big that they boggle the mind that someone might run out of it. – Jonathan Leffler Sep 29 '09 at 02:53
  • Excellent. I guess I was a was away yet. lol – DGM Sep 29 '09 at 03:17
  • 1
    As of macOS 10.12, the limit is still 262,144 (256 KB). Note that the limit only applies when invoking _external utilities_, not shell builtins. Compare `echo "$(printf "%$(getconf ARG_MAX)s")"` to `/bin/echo "$(printf "%$(getconf ARG_MAX)s")"` – mklement Jan 17 '17 at 17:54
  • High Sierra (10.13.1) here, still `262144`. – Siu Ching Pong -Asuka Kenji- Nov 29 '17 at 10:28
  • @JonathanLeffler Searching through a few thousand files will quickly make that number *very* small. – Clearer Apr 17 '18 at 13:37
  • Catalina 10.15 and still 262144 and I regularly run in to this when moving or copying large numbers of files with mv/cp/rm. It'll do about 5000ish before it complains. – jriskin Dec 04 '19 at 00:06
  • Big Sur 11.2.1 `getconf ARG_MAX` prints 1048576. In your face, Solaris!!! – Jeff Mar 18 '21 at 05:58
1

It depends on the shell, but the last time I ran a configure script using zsh on 10.6 it was 65535 characters.

Amok
  • 317
  • 3
  • 9