Changes

Jump to: navigation, search

Tutorial10: Shell Scripting - Part 1

135 bytes added, 14:17, 2 March 2021
Using Variables in Shell Scripts
''<b>User-defined variables</b> are variables which can be '''created by the user''' and exist in the session. This means that no one can access user-defined variables that have been set by another user,<br>and when the session is closed these variables expire.''<br>Reference: https://mariadb.com/kb/en/user-defined-variables/
<br><br>
Data can be stored and removed within a variable using an '''equal sign'''.<br><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.
<br><br>
'''Positional Parameters and Special Parameters'''
''Examples:''
<span style="font-family:courier;font-weight:bold">file $(ls)<br>mail -s "message" $(cat email-list.txt) < message.txt<br>echo "The current directory is $(pwd)"<br>echo "The current hostname is $(hostname)"<br>echo "The date is: $(date +'%A %B %d, %Y')"<br>
===Using Control Flow Statements in Shell Scripts===
13,420
edits

Navigation menu