Why do you need to put bin bash at the beginning of a script file

0 votes

It's a convention so the *nix shell knows what kind of interpreter to run.

For example, older flavors of ATT defaulted to sh (the Bourne shell), while older versions of BSD defaulted to csh (the C shell).

Even today (where most systems run bash, the "Bourne Again Shell"), scripts can be in bash, python, perl, ruby, PHP, etc, etc. For example, you might see #!/bin/perl or #!/bin/perl5.

PS: The exclamation mark (!) is affectionately called "bang". The shell comment symbol (#) is sometimes called "hash".

PPS: Remember - under *nix, associating a suffix with a file type is merely a convention, not a "rule". An executable can be a binary program, any one of a million script types and other things as well. Hence the need for #!/bin/bash.

Jun 20 in Linux Administration by Korak
• 5,820 points
13 views

1 answer to this question.

0 votes
It's a show so the *nix shell understands what sort of mediator to run.

For instance, more established kinds of ATT defaulted to sh (the Bourne shell), while more seasoned renditions of BSD defaulted to csh (the C shell).

Indeed, even today (where most frameworks run slam, the "Bourne Again Shell"), contents can be in slam, python, perl, ruby, PHP, and so forth, and so on. For instance, you could see #!/canister/perl or #!/receptacle/perl5.

PS: The interjection mark (!) is lovingly called "bang". The shell remark image (#) is once in a while called "hash".

PPS: Remember - under *nix, partner a postfix with a record type is only a show, not a "rule". An executable can be a parallel program, any of 1,000,000 content sorts and different things too. Consequently the requirement for #!/container/bash.505

It's a show so the *nix shell understands what sort of translator to run.

For instance, more seasoned kinds of ATT defaulted to sh (the Bourne shell), while more seasoned variants of BSD defaulted to csh (the C shell).

Indeed, even today (where most frameworks run slam, the "Bourne Again Shell"), contents can be in slam, python, perl, ruby, PHP, and so on, and so on. For instance, you could see #!/container/perl or #!/receptacle/perl5.

PS: The interjection mark (!) is tenderly called "bang". The shell remark image (#) is some of the time called "hash".

PPS: Remember - under *nix, partner a postfix with a document type is just a show, not a "rule". An executable can be a parallel program, any of 1,000,000 content sorts and different things too. Consequently the requirement for #!/container/slam.
answered Jun 20 by Rahul
• 3,380 points

Related Questions In Linux Administration

0 votes
2 answers

how to loop through the content of a file using bash

#!/bin/bash for i in  `cat peptides.txt` do echo $i done READ MORE

answered Sep 5, 2020 in Linux Administration by Prakash K. Aithal
1,680 views
0 votes
1 answer

How to check permissions of a file in the Linux system?

Hi@akhtar, If you prefer using the command line, ...READ MORE

answered Aug 13, 2020 in Linux Administration by MD
• 95,360 points
700 views
0 votes
1 answer

How to find the first field from a file in Bash Shell?

Hi@akhtar, You can extract text from a file. ...READ MORE

answered Oct 20, 2020 in Linux Administration by MD
• 95,360 points
281 views
0 votes
1 answer

Is there a limit on the number of words in bash command 'for file in words'?

Anyway, you need to print everything except ...READ MORE

answered May 27 in Linux Administration by Korak
• 5,820 points
16 views
0 votes
0 answers

How to detect the OS from a Bash script?

I would like to keep my .bashrc and .bash_login files in ...READ MORE

Jun 21 in Linux Administration by Korak
• 5,820 points
13 views
0 votes
0 answers

How to detect the OS from a Bash script?

I would like to keep my .bashrc and .bash_login files in ...READ MORE

Jun 22 in Linux Administration by Korak
• 5,820 points
4 views
0 votes
1 answer
0 votes
1 answer

Writing a heredoc to a file in a script

try to use tee: tee newfile <<EOF line 1 line 2 line ...READ MORE

answered May 20, 2019 in Linux Administration by Shubham
• 13,490 points
754 views
0 votes
1 answer

How do you copy and paste into Git Bash

Press Insert. Likewise, to duplicate from the window, ...READ MORE

answered Jun 20 in Linux Administration by Rahul
• 3,380 points
17 views
0 votes
1 answer

What does '-gt' operator mean in Bash programming?

It's a math test. assist with testing ...READ MORE

answered Jun 20 in Linux Administration by Rahul
• 3,380 points
12 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP