AMITY UNIVERSITY RAJASTHAN
PRESENTED BY:
ASHISH KUMAR
MCA 4TH SEMESTER.
Roll NO : AUR 1351016
(AMITY INSTITUTE OF INFORMATION TECHNOLOGY)
Presentation on
Positional Parameter In Unix
 A positional parameter is a parameter whose position on the command line
is important to the program reading it.
 Positional parameters are a series of special variables ($0 through $9) that
contain the contents of the command line. If some program were a bash shell
script, we could read each item on the command line.
Special bash parameter Meaning
$# $# is quite a special bash parameter and it
expands to number of positional parameters in
decimal.
$0 $0 bash parameter is used to reference name of
the shell or shell script. so you can use this if you
want to print name of shell script.
$- $- (dollar hyphen) bash parameter is used to get
current option flags specified during invocation,
by the set built-in command or set by the bash
shell itself. Though this bash parameter is rarely
used.
$? $0 is one of the most used bash parameter and
used to get the exit status of the most recently
executed command in foreground. By using this
you can check whether your bash script is
completed successfully or not.
$_ $_ (dollar underscore) is another special bash
parameter and used to reference the absolute file
name of the shell or bash script which is being
executed as specified in the argument list. This
bash parameter is also used to hold the name of
mail file while checking mails.
$@ $@ (dollar at the rate) bash parameter is used to
expand into positional parameters starting from
one. When expansion occurs inside double quotes,
every parameter expands into separate words.
$* $* (dollar star) this is similar to $@ special bash
parameter only difference is when expansion
occurs with double quotes, it expands to a single
word with value of each bash parameter
separated by the first character of special
variable.
Special bash character Meaning
# # is used to comment a single line in
bash script
$$ $$ is used to reference process id of
any command or bash script
$name $name will print the value of
variable “name” defined in script.
$n $n will print value of nth argument
provided to bash script (n ranges
form 0 to 9) e.g. $1 will print first
argument.
> > is used to redirect output
>> >> can be used to Append to file
< < will redirect input
[ ] [] are for matching any characters
enclosed
( ) Execute in sub shell
` ` Another powerful special bash character
which is used to substitute output of
enclosed command
" " Partial quote (allows variable and
command expansion)
' ' Full quote (no expansion)
 Quote following character
| Pipe output of one command to another
most useful and immensely power bash
character
& & is used to run any process in
background.
; ;(semi colon ) is used to separate
commands on same line
* * is used to match any character(s) in
filename
? ? is for matching single character in
filename
Unix ppt

Unix ppt

  • 1.
    AMITY UNIVERSITY RAJASTHAN PRESENTEDBY: ASHISH KUMAR MCA 4TH SEMESTER. Roll NO : AUR 1351016 (AMITY INSTITUTE OF INFORMATION TECHNOLOGY) Presentation on Positional Parameter In Unix
  • 2.
     A positionalparameter is a parameter whose position on the command line is important to the program reading it.  Positional parameters are a series of special variables ($0 through $9) that contain the contents of the command line. If some program were a bash shell script, we could read each item on the command line.
  • 3.
    Special bash parameterMeaning $# $# is quite a special bash parameter and it expands to number of positional parameters in decimal. $0 $0 bash parameter is used to reference name of the shell or shell script. so you can use this if you want to print name of shell script. $- $- (dollar hyphen) bash parameter is used to get current option flags specified during invocation, by the set built-in command or set by the bash shell itself. Though this bash parameter is rarely used. $? $0 is one of the most used bash parameter and used to get the exit status of the most recently executed command in foreground. By using this you can check whether your bash script is completed successfully or not.
  • 4.
    $_ $_ (dollarunderscore) is another special bash parameter and used to reference the absolute file name of the shell or bash script which is being executed as specified in the argument list. This bash parameter is also used to hold the name of mail file while checking mails. $@ $@ (dollar at the rate) bash parameter is used to expand into positional parameters starting from one. When expansion occurs inside double quotes, every parameter expands into separate words. $* $* (dollar star) this is similar to $@ special bash parameter only difference is when expansion occurs with double quotes, it expands to a single word with value of each bash parameter separated by the first character of special variable.
  • 5.
    Special bash characterMeaning # # is used to comment a single line in bash script $$ $$ is used to reference process id of any command or bash script $name $name will print the value of variable “name” defined in script. $n $n will print value of nth argument provided to bash script (n ranges form 0 to 9) e.g. $1 will print first argument. > > is used to redirect output >> >> can be used to Append to file < < will redirect input
  • 6.
    [ ] []are for matching any characters enclosed ( ) Execute in sub shell ` ` Another powerful special bash character which is used to substitute output of enclosed command " " Partial quote (allows variable and command expansion) ' ' Full quote (no expansion) Quote following character
  • 7.
    | Pipe outputof one command to another most useful and immensely power bash character & & is used to run any process in background. ; ;(semi colon ) is used to separate commands on same line * * is used to match any character(s) in filename ? ? is for matching single character in filename