Open main menu

CDOT Wiki β

Changes

Tutorial10: Shell Scripting - Part 1

13 bytes removed, 08:32, 16 March 2021
INVESTIGATION 2: SHE-BANG LINE / VARIABLES / PARAMETERS
# Add the following lines to the beginning of the ''user-variables.bash'' file:<br><span style="font-family:courier;font-weight:bold;">#!/bin/bash<br>read -p "Enter your Full Name: " name<br>read -p "Enter your age (in years): " age<br>echo "Hello $name - You are $age years old"</span><br><br>
# Save your editing changes and exit your text editor.<br><br>[[Image:user-variable1.png|thumb|right|300px|Prompting user to enter data via the '''read -p''' command storing into '''user-created variable'''.]]
# Issue the '''chmod''' command to add '''execute permissions''' for the user for the '''user-variables.bash''' file.<br><br>
# Issue the following to run the user-variables.bash Bash shell script<br> (enter your Full name and age when prompted):<br><span style="color:blue;font-weight:bold;font-family:courier;">./user-variables.bash</span><br><br>What did you notice?<br><br>
# Use a text editor to '''modify''' your Bash shell script called '''user-variables.bash'''<br><br>
13,420
edits