Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In connection with developing GNU Parallel I seem to have hit a limit in the length of #! (shebang). This shebang-line:

#!/bin/echo 123456789a123456789b123456789c123456789d123456789e123456789f123456789g123456789h123456789i123456789j123456789k123456789done bar

prints this on Debian, Mandriva, SuSE, Ubuntu, Centos, RedHat:

123456789a123456789b123456789c123456789d123456789e123456789f123456789g123456789h123456789i123456789j123456789k12345 ./shebang

So it seems to be chopped off after 128 bytes. But it does what I would expect (printing the full line) on FreeBSD, DragonFlyBSD and Hurd. On OpenBSD and Tru64 it prints nothing(?!).

What causes this limitation? Can I work around it?


GNU Parallel's --shebang makes it possible to write the full parallel command in the #!-line. It is therefore somewhat limiting if the full command can only be 128 chars.

The rest of the file is used as input for parallel, thus the command cannot be written there.

share|improve this question
That's what heredocs are for. – Ignacio Vazquez-Abrams Aug 21 '13 at 4:41
@IgnacioVazquez-Abrams Is there a heredoc construct that will allow any input (including \0, \n, the heredoc string and any combination of those)? My input can be a binary file, so it is not an acceptable solution if certain strings in the input are forbidden. – Ole Tange Aug 21 '13 at 4:55
Hrm. No, but you could use a sentinel at the end of the text portion and append the binary data afterwards. This technique is often used by installers. – Ignacio Vazquez-Abrams Aug 21 '13 at 5:00
@IgnacioVazquez-Abrams Which sentinel can be used, if the user may use the sentinel as data in for his use? It seems you think that I control the data: I do not. The whole point of GNU Parallel is letting the user control the data and still "do the right thing". – Ole Tange Dec 17 '14 at 18:32
up vote 2 down vote accepted

Limit of length depends on implementation. I recently investigated similar question and I found this wonderful report by Sven Mascheck about shebang line in different versions of Unix and Linux. You should definitely take a look. It says that, in particular, shebang line originally was limited to 16 bytes.

share|improve this answer
Funny, I can see in my browser that I have visited that page earlier, but I clearly did not read the length section. – Ole Tange Dec 14 '13 at 11:21

Take a look at, it includes a few techniques on how to fix this issue: kernel recompile or a shebang wrapper script (most users would prefer the latter).

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.