I am wondering if there is any size, length or even run-time limitations with bash scripts. I am installing php-hiphop on debian squeeze(I know it's not ubuntu but I presumed there were some bash experts hanging around here) on a test server, and there is quite a lot of extra libraries and configuring to do before even attempting to compile hiphop so I plan to make a bash script so that updating other servers will be quicker. I'm pretty new to linux systems, this is actually my first time properly using one, and I have no idea how much or how little bash files can do.

As an example, I have to update gcc to 4.6 which at the make command is taking 5+ hours, and was wondering even after that long will the bash script be able to continue? I have also noticed one can use multiple bash scripts and use wait to wait for a command to finish then execute another script, would this be a better approach?

Thanks in advance.

  • Size limit? lol If you have a bash file that's over a megabyte in size, then you'd probably be better off using a real programming language. Though, a bash script could be way over 100 megabytes in size if you really want to know. :) – Sepero Oct 24 '12 at 15:18
  • Ha I should have phrased that better. I suppose size is the wrong word here, I mean "amount of commands" or something like that. – boundless08 Oct 24 '12 at 15:32
  • If the command you want will work in the terminal, then it will work in a bash script. As for the number of commands- I suppose that is only limited by your hardware. – Sepero Oct 24 '12 at 15:38
  • Thanks Sepero, really helps. I'll let you know how my 4.76GB bash file went when I finish running it :P – boundless08 Oct 24 '12 at 15:45

I have never run into limitations on size or time, and as long as your script isn't hampering the system in some way-there is no limitation.

I have a script that backs up all my servers to a network location, it runs for 19 hours. as far as sizes? scripts are only text files, how big could it get? bash scripting a great because of its few limitations, enjoy!

hope this answers your question!

thanks jm

  • 1
    Thanks that really helps. I don't mean size as in memory, although I should have phrased it better, I kind of meant it as number of commands, as in "the size of what it does". I swear it makes sense in my head. – boundless08 Oct 24 '12 at 15:31
  • oh, well that shouldn't matter either, my back up script is about 60 commands. 1 create backup, 2 move backup, 3, verify.. then repeat for 20 servers. good luck scripting! – jmartin2279 Oct 25 '12 at 8:35
  • I seem to have an issue where bash's character buffer is only so large... Apparently my 12,000-line is too big - bash gives a syntax error about an unexpected newline. – iAdjunct May 11 '16 at 22:49
  • @iAdjunct: take a look at this answer on StackOverflow and the Unix/Linux answer it links to. – rici Jul 29 '16 at 18:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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