The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
meaning of ${0%${0##*/}} nyelavarthy AIX 7 09-23-2008 02:48 AM
if [ ! -r ${1} ] meaning in ksh naveeng.81 Shell Programming and Scripting 1 04-09-2008 01:47 PM
OopenSSH not letting me in! BG_JrAdmin SUN Solaris 2 09-12-2006 11:54 AM
what is the meaning here? forevercalz Shell Programming and Scripting 2 09-29-2005 12:46 PM
client app not letting go of socket fusion99 UNIX for Dummies Questions & Answers 1 02-20-2004 10:13 AM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-04-2009
jojo123 jojo123 is offline
Registered User
  
 

Join Date: May 2009
Posts: 50
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 ....

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 11:30 AM.. Reason: added code tags and changed subject for user, cost 15000 bits
Bits Awarded / Charged to jojo123 for this Post
Date User Comment Amount
07-04-2009 Neo changed title, added code tags.... do it yourself per rules. -15,000
  #2 (permalink)  
Old 07-04-2009
Neo's Avatar
Neo Neo is offline Forum Staff  
Administrator
  
 

Join Date: Sep 2000
Location: Asia Pacific
Posts: 6,518
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 (permalink)  
Old 07-04-2009
scottn scottn is offline Forum Advisor  
VIP Member
  
 

Join Date: Jun 2009
Location: Zürich, CH
Posts: 967
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 scottn; 07-04-2009 at 12:43 PM..
  #4 (permalink)  
Old 07-04-2009
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,116
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 (permalink)  
Old 07-04-2009
scottn scottn is offline Forum Advisor  
VIP Member
  
 

Join Date: Jun 2009
Location: Zürich, CH
Posts: 967
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 scottn; 07-04-2009 at 12:47 PM..
Sponsored Links
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 10:51 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0