Begin every Bash script
This page was last updated on April 03, 2010.
- Make this the first line of every Bash script:
-
#!/bin/bash
- Or make this the first line of every Bash script when you’d like to avoid the default behavior of having Bash read /etc/profile (the system-wide startup file) or ~/.bash_profile, ~/.bash_login, or ~/.profile (any of the personal initialization files):
-
#!/bin/bash --noprofile
Obligatory Happy Ending
And they all lived happily ever after. The end.

I would say something like this is better if you’re writing just a shell script:
#!/bin/bash –noprofile
You don’t need all the overhead of processing the startup scripts just to fork a process that already has a PATH, HOME, etc.
Comment by Jerry — April 3, 2010 @ 2:22 pm
Good point! I’m adding it now.
Comment by mostlylinux — April 3, 2010 @ 8:36 pm