help me out in letting me know the meaning of sh, ksh, bash


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting help me out in letting me know the meaning of sh, ksh, bash
# 1  
Old 07-04-2009
help me out in letting me know the meaning of sh, ksh, bash

Could you please help me out in letting me know the meaning of

Code:
#!/bin/sh
#!/bin/ksh
#!/bin/bash

what the difference between all these Smilie....

Also please view the below mention script, could you please explain whats this script doing

Code:
#!/bin/bash
t=100
echo $t
echo $tea
echo ${t}ea

Thnkz in advance.

Last edited by Neo; 07-04-2009 at 12:30 PM.. Reason: added code tags and changed subject for user, cost 15000 bits
# 2  
Old 07-04-2009
Hello,

Per our forum rules, all threads must have a descriptive subject text. For example, do not post questions with subjects like "Help Me!", "Urgent!!" or "Doubt". Post subjects like "Execution Problems with Cron" or "Help with Backup Shell Script".

The reason for this is that nearly 95% of all visitors to this site come here because they are referred by a search engine. In order for future searches on your post (with answers) to work well, the subject field must be something useful and related to the problem!

In addition, current forum users who are kind enough to answer questions should be able to understand the essence of your query at first glance.

So, as a benefit and courtesy to current and future knowledge seekers, please be careful with your subject text. You might receive a forum infraction if you don't pay attention to this.

Thank you.

The UNIX and Linux Forums
# 3  
Old 07-04-2009
The first line of a script specifies what "language" the script is written in (and should be used to execute what follows).

Code:
#!/bin/sh       - means Bourne shell
#!/bin/ksh      - means Korn shell
#!/bin/bash     - means Bourne Again shell
#!/usr/bin/perl - means Perl

Code:
#!/bin/bash
t=100            - sets a variable called t to 100
echo $t          - prints the value of variable t
echo $tea        - prints the value of variable tea
echo ${t}ea      - prints the value of t followed by the literal characters ea

{ and } are used to separate a variable name from other text - otherwise the shell can't distinguish the variable name from the other text.

Last edited by Scott; 07-04-2009 at 01:43 PM..
# 4  
Old 07-04-2009
Code:
$ cat scott.sh
#!/bin/bash
t=100
echo "\$t ->[$t]"
echo "\$tea ->[$tea]"
tea=foo
echo "\$tea ->[$tea]"
echo "\${t}ea ->[${t}ea]"
$
$ ./scott.sh
$t ->[100]
$tea ->[]
$tea ->[foo]
${t}ea ->[100ea]

# 5  
Old 07-04-2009
I missed out the word "not". But reading it back, the grammer is pretty rubbish too.

Simpler would be
Quote:
${t}ea is not the same as $tea
Should have quit while I was ahead.

I should use:
#!/bin/english

I know what I was trying to say, here, but just made a complete mess of it...
Quote:
If you set a variable called "tea" to 100, then ${t}ea and $tea would not mean the same thing, but if your intention was to add ea to $t, then you need the { }.
So I removed it from the original post.

Last edited by Scott; 07-04-2009 at 01:47 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

BASH to KSH

I have a script in KSH and now need to incorporate this into another script which is in BASH. OUr script contains code like below in good number of places. Eg: echo “A B C” | read VAR1 VAR2 VAR3 This works only in ksh and not in BASH. Please let me know 1. Which is the equivalent... (3 Replies)
Discussion started by: cvsanthosh
3 Replies

2. Shell Programming and Scripting

meaning of #!/bin/ksh -p

:b:HI Friends, Can you help me understand -p option with /usr/bin/ksh shell interpreter ? Thanks, Panditt (1 Reply)
Discussion started by: deshaipet
1 Replies

3. Shell Programming and Scripting

ksh vs bash

what is diff between KSH and Bash can you tell me some commands which run in either of two but not in both. while doing normal shell programming I am unable to find diffrence between two (2 Replies)
Discussion started by: pasricha.kunal
2 Replies

4. UNIX for Dummies Questions & Answers

bash preferred or ksh with bash features

I'm a user on a fairly locked down sys V server. By default, I have ksh set as my default shell. I added to my .profile: bash -o vi so when I login, it goes into bash so I can take advantage of tab completion and use the up key to bring up previous commands. However, whenever I want to exit, I... (2 Replies)
Discussion started by: mrwatkin
2 Replies

5. Shell Programming and Scripting

bash and ksh: variable lost in loop in bash?

Hi, I use AIX (ksh) and Linux (bash) servers. I'm trying to do scripts to will run in both ksh and bash, and most of the time it works. But this time I don't get it in bash (I'm more familar in ksh). The goal of my script if to read a "config file" (like "ini" file), and make various report.... (2 Replies)
Discussion started by: estienne
2 Replies

6. Shell Programming and Scripting

if [ ! -r ${1} ] meaning in ksh

hi, iam new of unik if meaning in ksh (1 Reply)
Discussion started by: naveeng.81
1 Replies

7. Shell Programming and Scripting

Need help : KSH>BASH

Hello, I've written a script in KSH, but now it needs to run on a system without KSH, ie sh or bash etc, bash seems best bet, but the simplest of things don't seem to work.. The snippet below is the main issue, basically I'm reading from a dat file and putting fields into arrays.. Dat file... (5 Replies)
Discussion started by: itsupplies
5 Replies

8. Solaris

OopenSSH not letting me in!

I just installed openssh on my machine, and i keep getting the error in the log: Any idea what is causeing this, i tried changing the IP its listening to in sshd_config, but that didnt help.. any ideas are appreciated, thanks!! Sep 1 14:05:13 wintest sshd: Server listening on 0.0.0.0 port... (2 Replies)
Discussion started by: BG_JrAdmin
2 Replies

9. Shell Programming and Scripting

Ksh vs Bash

Hi Buddy, Can any one help me to overcome from the below problem? #/usr/bin/ksh typeset -Z dd dd=1 echo $dd =========== out put for the above is 01 same script I'm migrating to bash but typeset -Z option is not found in bash, Pls get me the equivalent option in BASH Thanks in... (1 Reply)
Discussion started by: krishna
1 Replies

10. UNIX for Dummies Questions & Answers

client app not letting go of socket

Ok here's the situation We have an application that our users log into over the network to one of our unix boxes (Solaris 8). I had this situation occur the other day where an user claimed that he totally shutdown the app because it froze up and wasn't able to log back in. I performed a... (1 Reply)
Discussion started by: fusion99
1 Replies
Login or Register to Ask a Question