Changes

Jump to: navigation, search

Tutorial10: Shell Scripting - Part 1

6 bytes added, 13:47, 17 February 2021
INVESTIGATION 2: USING VARIABLES IN SHELL SCRIPTS
# Use a text editor to create a file called '''parameters.bash'''<br><br>
# Add the following lines to the beginning of this file:<br><span style="font-family:courier;">#!/bin/bash<br>echo \$0: $0<br>echo \$2: $2<br>echo \$3: $3<br><br>echo \$#: $#<br>echo \$*: $*<br><br>shift 2<br>echo \$#: $#<br>echo \$*: $*</span><br><br>
# Save your editing changes and exit your text editor.<br><br>Notice how the quoting character "'''\'''" is used to display positional parameters like "'''$2'''"<br>as opposed to the value stored in the <u>second</u> positional parameter.<br><br>
# Issue the '''chmod''' command to add execute permissions for the user for the '''parameters.bash''' file.<br><br>
# Issue the following to run the '''user-variables.bash''' Bash shell script:<br><span style="color:blue;font-weight:bold;font-family:courier;">./parameters.bash</span><br><br>What happened?<br><br>The values for the parameters may not be displayed properly since you did NOT provide any arguments when running the shell script.<br><br>
13,420
edits

Navigation menu