Location parameters
$0, $1, $2, and so on...
Location parameter, which is passed to the script from the command line, to the function, or to a variable.
(For details, see Example 4-5 and example 11-15)
$ #
Number of command lines or location parameters (see example 33-2)
$ *
All location parameters are used as a word.
Note: "$ *" must be referenced.
$ @
It is synonymous with $ *, but each parameter is an independent "" reference string, which means that the parameter is completely passed,
It is not interpreted and extended. This also means that each parameter in each parameter list is treated as an independent
Word.
Note: "$ @" must be referenced.
For details, see the code:
#! /Bin/bash
# Arglist. Sh
E_badargs = 65
If [! -N "$1"]
Then
Echo "Usage: 'basename $ 0' argument1 argument2 etc ."
Exit $ E_BADARGS
Fi
Echo
Index = 1
Echo "Listing args with \" \ $ *\":"
For arg in "$ *"
Do
Echo "Arg # $ index = $ arg"
Let "index + = 1"
Done
Echo "Entire arg list seen as single word ."
Echo
Index = 1
Echo "Listing args with \" \$ @\":"
For arg in "$ @"
Do
Echo "Arg # $ index = $ arg"
Let "index + = 1"
Done
Echo "Arg list seen as separate words ."
Echo
Index = 1
Echo "Listing args with \ $ * (unquoted ):"
For arg in $ *
Do
Echo "Arg # $ index = $ arg"
Let "index + = 1"
Done
Echo "Arg list seen as separate words ."
Exit 0
#! /Bin/bash
Echo 'in in work'
Binhome = 'dirname $0'
Echo $ binhome
CD $ binhome
Binhome = 'pwd'
Echo $ binhome
WorkHome =$ {binHome }/..
Echo $ workHome
B =$ {workHome}/common/date. sh
Echo $ B
Source $ {workHome}/common/date. sh
Index = 1
For arg in $ *
Do
If [["x $ arg" = "x"]; then
Exit 1
Else
Case $ index in
1)
LoadDate = $ arg
;;
2)
Days = $ arg
;;
*)
ExecFile = $ arg
ExecDate =$ {loadDate}
For (I = 0; I <days; I = I + 1 ))
Do
Bash $ {execFile }$ {execDate}
ExecDate = 'dashdateadd $ {execDate} '1''
Done
;;
Esac
Let "index + = 1"
Fi
Done
Exit 0