Changes

Jump to: navigation, search

Tutorial10: Shell Scripting - Part 1

4 bytes added, 11:45, 3 September 2020
INVESTIGATION 2: USING VARIABLES IN SHELL SCRIPTS
# Re-run the '''hello.bash''' shell script by just using the name.<br><br>What did you notice?<br><br>The setting of the '''PATH''' environment variable only worked in the current session only.<br>If you exit the current Matrix session, then the recently changed settings for environment variables will be lost.<br>You will in a future tutorial how to set environment variables in startup files.<br><br>Let's create a Bash shell script that contain '''user-created variables'''.<br><br>
# Use a text editor to create a file called '''user-variables.bash'''<br><br>
# Add the following lines to the bottom beginning of the this file:<br><span style="font-family:courier;">#!/bin/bash<br>age=25<br>readonly age<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>
# Issue the '''chmod''' command to add execute permissions for the user for the '''user-variables.bash''' file.<br><br>
13,420
edits

Navigation menu