[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: bash scripts and files



2007/12/30, michael <cs@networkingnewsletter.org.uk>:
> Folks, can somebody point me to an authorative reference that
> explains when one needs to put, eg,
>   #!/bin/bash
> as the first line of a script and whether or not it's required/
> surplus/ignored for bash specific files such as .bashrc
> and .bash_profile
>
> many thanks but couldn't find it quickly using 'oogle. M

In a script that line specifies the interpreter to use to execute the
following lines on the script. It may be any interpreter that you
want: bash, sh, ksh, perl, python,etc..

In .bashrc, .bash_profile or other files that are "included" from
other interpreter/scripts you dont need the interpreter line.

As a note, if you are planning to write portable scripts, please use
#!/bin/sh and avoid "bashism" (like [ $foo -ge 1 ]) in the syntax.

Greetings


Reply to: