![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
ksh and sh
What is the difference between a script starting with:
#!/bin/ksh and #!/bin/sh thanks |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Quote:
Sh is bourne shell. Script starting with #!/bin/ksh is executed by Korn shell Script starting with #!/bin/sh is executed by Bourne shell |
|
#3
|
|||
|
|||
|
Quote:
The problem is that I have that simple script here: Quote:
|
|
#4
|
|||
|
|||
|
Quote:
|
|
#5
|
|||
|
|||
|
The file is sysdba.sh and the first line of the file is #!/bin/ksh
|
|
#6
|
|||
|
|||
|
the #!/bin/ksh at the top of the file define what the following commands in the script use as an interpreter, in this case /bin/ksh (the korn shell)
you can put practically any interpretive shell command there, i.e. #!/usr/bin/awk for awk #!/usr/bin/perl for perl and so on. putting a ':' there will mean use the default shell the difference between sh and ksh (bourne and korn) is mostly functionality. i.e. ksh has variable substitutions, dimensioned arrays, etc |
|
#7
|
|||
|
|||
|
Also good to know is anything written for bourne shell can run in korn shell. As TinWalrus stated, korn shell has more functionality.
Now the #! ( pronounced Shebang ) line of the script just tells the script what shell to use when executing. So say you use bourne shell and have a script that uses functionality of korn shell you could run the script in your bourne shell provided you have included the line #!/usr/bin/ksh If you didn't include this, your script might return an error. ( Thanks for the correction reborg. ) Last edited by lazytech; 05-07-2007 at 08:24 AM. Reason: Incorrect statement. Thanks for the catch reborg! |
|||
| Google The UNIX and Linux Forums |