Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting


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

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 07-31-2012
Registered User
 
Join Date: Jan 2008
Location: I live in Pretoria, South Africa
Posts: 50
Thanks: 8
Thanked 0 Times in 0 Posts
decipher shell commands

Hi Guys,

I am busy trying to re-write a shell script that was written way back.

I need help with these codes:


Code:
# Process switches
if [ $? -gt 1 ] ; then
  echo "usage : process <optional instance>"
  exit 99
fi

What does the above code mean?

What does these $? -gt 1 mean?

Then I have these---


Code:
SIDA=true
SIDB=true

if [ $# -eq 1 ] ; then
  if [ $1 = "SIDA" ] ; then
    SIDB=false
  fi
  if [ $1 = "SIDB" ] ; then
    SIDA=false
  fi
fi

What does these mean?

What does $ mean in shell scripting and where can I learn more about using this in my scripts?

Thanks in advance....

Last edited by Scott; 07-31-2012 at 04:17 AM.. Reason: Code tags, please...
Sponsored Links
    #2  
Old 07-31-2012
itkamaraj's Avatar
^Kamaraj^
 
Join Date: Apr 2010
Posts: 3,025
Thanks: 33
Thanked 647 Times in 625 Posts
Unix - Special Variables
Sponsored Links
    #3  
Old 07-31-2012
RudiC RudiC is offline Forum Advisor  
Registered User
 
Join Date: Jul 2012
Location: Aachen, Germany
Posts: 1,881
Thanks: 25
Thanked 433 Times in 419 Posts
The $ sign expands (=replaces) parameters/variables to (with) their contents. 1, 2, ... are positional parameters, of which $# is the count; $? yields the exit code/status of your last command. Read the man page of your shell.
    #4  
Old 07-31-2012
Registered User
 
Join Date: Jan 2008
Location: I live in Pretoria, South Africa
Posts: 50
Thanks: 8
Thanked 0 Times in 0 Posts
Thanks for the replies...
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
can you decipher this script ? llcooljatt SuSE 7 12-10-2011 07:57 AM
Can you decipher this script ? llcooljatt Shell Programming and Scripting 1 11-01-2011 07:48 AM
Sed - Unable to decipher this. sid1982 Shell Programming and Scripting 6 02-17-2010 03:07 PM
Can BASH execute commands on a remote server when the commands are embedded in shell bash_in_my_head Shell Programming and Scripting 1 12-04-2008 12:51 AM
help me decipher how much memory on my box JamesByars HP-UX 3 10-17-2008 08:18 PM



All times are GMT -4. The time now is 05:53 PM.