Open main menu

CDOT Wiki β

Changes

Tutorial10: Shell Scripting - Part 1

52 bytes removed, 09:02, 15 July 2020
Using Variables in Shell Scripts
A '''positional parameter''' is a variable within a shell program; its value is set from an argument specified<br>on the command line that invokes the program.
Positional parameters are numbered and are referred to<br>with a preceding "'''$'''": '''$1''', '''$2''', '''$3''', and so on. The positional parameter $0 refers to either the name of shell where command was issued, or name of shell script being executed.
There are a few ways to assign values as positional parameters:
:*Use the '''set''' command with the values as argument after the set command
:*Run a shell script containing arguments
 
Command line parameters are referred to as $0…$9
The positional parameter $0 refers to either the name of shell where command was issued, or name of shell script being executed.
If using positional parameters greater than 9, then you need to include number within braces.
13,420
edits