Changes

Jump to: navigation, search

Tutorial10: Shell Scripting - Part 1

142 bytes added, 09:10, 15 July 2020
Using Variables in Shell Scripts
Data can be stored and removed within a variable using an equal sign.<br>The '''read''' command can be used to prompt the user to enter data into a variable.<br>Refer to the diagram on the right-side to see how user-defined variables are assigned data.
'''Positional Parameters and Special Parameters'''
[[Image:positional.png|thumb|right|300px|Examples of using '''positional''' and '''special''' parameters.]]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<br>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.<br>Examples: '''echo ${10}''', '''ls ${23}'''
The '''shift''' command can be used with positional parameters to shift positional parameters<br>to the left by one or more positions.
There are a group of '''special parameters ''' that can be used for shell scripting.<br>A few of these special parameters and their purpose are displayed below:<br>'''$*''' , '''“$*”''' , '''"$@"''' , '''$#''' , '''$?'''
===Using Control Flow Statements in Shell Scripts===
13,420
edits

Navigation menu