Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

Debian GNU/Linux Reference Guide
Prev Home Next

13.2.3 Shell parameters

Several special parameters to remember:

     $0      = name of the shell or shell script
     $1      = first(1) shell argument
      ...
     $9      = ninth(9) shell argument
     $#      = number of positional parameters
     "$*"    = "$1 $2 $3 $4 ... $n"
     "$@"    = "$1" "$2" "$3" "$4" ... "$n"
     $?      = exit status of the most recent command
     $$      = PID of this shell script
     $!      = PID of most recently started background job

Basic parameter expansions to remember:

         Form        If var is set       If var is not set
     ${var:-string}  $var                string
     ${var:+string}  string              null
     ${var:=string}  $var                string 
                                         (and run var=string)
     ${var:?string}  $var                (echo string and then exit)

Here, the colon `:' in all of these operators is actually optional.

  • With `:' = operator test for "exist" and "not null".

  • Without `:' = operator test for "exist" only.

Basic parameter substitutions to remember:

         Form        Result
     ${var%suffix}   Remove smallest suffix pattern
     ${var%%suffix}  Remove largest suffix pattern
     ${var#prefix}   Remove smallest prefix pattern
     ${var##prefix}  Remove largest prefix pattern

Debian GNU/Linux Reference Guide
Prev Home Next

 
 
  Published under the terms of the GNU General Public License Design by Interspire