33 lines
903 B
Bash
33 lines
903 B
Bash
#!/bin/bash -e
|
|
|
|
#####################################################
|
|
#
|
|
# Variables are stored values that can be set locally
|
|
# in the script or inherited from your environment.
|
|
#
|
|
# Usage: bash bash/variables.sh
|
|
#
|
|
#####################################################
|
|
|
|
# Set this variable to run the script
|
|
VARIABLE=""
|
|
NUMBER=3
|
|
|
|
# Save output of the command "pwd" to a variable
|
|
# by running it in a subshell
|
|
CURRENT_DIR=`pwd`
|
|
|
|
# A different notation for subshells, this time
|
|
# saving the contents of a text file to a variable
|
|
FILE=$(cat text/cat1.txt)
|
|
|
|
if [ "${VARIABLE}" != "" ]; then
|
|
echo "Your variable: ${VARIABLE}"
|
|
echo "Your number: ${NUMBER}"
|
|
echo "Your current dir: ${CURRENT_DIR}"
|
|
# $PATH is an environment variable set by your system
|
|
echo "Your username: ${USER}"
|
|
echo "Your system \$PATH: ${PATH}"
|
|
else
|
|
echo "Please create within the quotes on line 13"
|
|
fi |