Using #! /bin/sh in Shell scripts


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Using #! /bin/sh in Shell scripts
# 1  
Old 12-01-2006
Using #! /bin/sh in Shell scripts

Hi All,

What does #! /bin/sh mean in a shell script? Is it mandatory to include in a shell script? I'm able to execute the shell script without it.

Any help on this would be appreciated.
sumesh.abraham
# 2  
Old 12-01-2006
it actually tells the script to which interpreter to refer. As you know, bash shell has some specific functions that other shell does not have and vice-versa. Same way is for perl, python and other languages.
# 3  
Old 12-01-2006
Thanks for the info. I still have doubts. If this information is not provided, how the path of the interpreter is assumed?
sumesh.abraham
# 4  
Old 12-01-2006
Do people ever read the FAQ's or even use the search feature ? Smilie

See https://www.unix.com/showthread.php?t=7077
This User Gave Thanks to vino For This Post:
# 5  
Old 12-01-2006
Right. You should do what vino says before asking. Anyway, If you don't specify that information, the user's default shell will be used.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Usage of #!/bin/sh vs #!/bin/bash shell scripts?

Some question about the usage of shell scripts: 1.) Are the commands of the base shell scripts a subset of bash commands? 2.) Assume I got a long, long script WITHOUT the first line. How can I find out if the script was originally designed für "sh" or "bash"? 3.) How can I check a given... (3 Replies)
Discussion started by: pstein
3 Replies

2. Shell Programming and Scripting

shell type.. /bin/uvalid?

Hi, I gave a command echo $SHELL --> To find out the shell I'm using, which gave me the below output echo $SHELL /bin/uvalid what does it mean? Please use code tags when posting data and code samples, thank you. (1 Reply)
Discussion started by: dnam9917
1 Replies

3. OS X (Apple)

When to use /Users/m/bin instead of /usr/local/bin (& whats the diff?)?

Q1. I understand that /usr/local/bin means I can install/uninstall stuff in here and have any chance of messing up my original system files or effecting any other users. I created this directory myself. But what about the directory I didn't create, namely /Users/m/bin? How is that directory... (1 Reply)
Discussion started by: michellepace
1 Replies

4. Shell Programming and Scripting

[Bourne shell] Asking stuff with #!bin/sh urgent!

1. Accept a “userid” as a command line argument 2. Produce the following output: User userid has a home directory of /path/directory the default shell for this user is /path/shell 3. At this level, it may be assumed that the “userid” is a unique string in the file that is being searched 4.... (17 Replies)
Discussion started by: grandios
17 Replies

5. Solaris

Questions about /usr/local/bin & scripts.

Hi gentlemen. For what intended is the directory /usr/local/bin? In this directory are some script. I don't understand how these scripts being in this directory are started. Each time after registration of the user occurs start of these scripts. These scripts start applications. (7 Replies)
Discussion started by: wolfgang
7 Replies

6. UNIX for Dummies Questions & Answers

fuser: difference with bin/sh and bin/ksh shell script

Hi, I have a problem I don't understand with fuser. I launch a simple shell script mysleep.sh: I launch the command fuser -fu mysleep.sh but fuser doesn't return anything excepted: mysleep: Then I modify my script switching from #!/bin/sh to #!/bin/ksh I launch the command fuser -fu... (4 Replies)
Discussion started by: Peuj
4 Replies

7. Shell Programming and Scripting

Scripts in ~/bin vs. functions in ~/.bashrc

Hi there, Anyone knows what would be the cons and pros of adding a script in ~/bin vs. a function in ~/.bashrc? I'm not sure how the system keeps tracks of some of the settings loaded in ~/.bashrc (like functions and aliases). Would I be right in thinking that this would all be loaded into... (2 Replies)
Discussion started by: victorbrca
2 Replies

8. Shell Programming and Scripting

[/bin/sh] passing parameters with quotes between 2 scripts

Hi, I have a first shell script (/bin/sh) that receives some paremeters. This is only an example (there are more parameters in fact and this one is among them): -header "This is a test" This script calls a secund shell script (/bin/sh) with the same parameters. But, quotes disappear as I would... (0 Replies)
Discussion started by: velo_love
0 Replies

9. Shell Programming and Scripting

#!/bin/sh shell question

HI, Nice to meet u... I am a newbie. I have met a problem in the work as following: SRCLOG="/Share/log/testlog/*" SRCLOG="/Share/log/systemlog/*" SRCLOG="/Share/log/log.conf" SRCLOG="/Share/log/message" How can I get the file or directory value from each element of... (0 Replies)
Discussion started by: GCTEII
0 Replies
Login or Register to Ask a Question