- Make sure you are in tab that says main.sh
- Type the Scripts Below, one at a time.
- Click Execute to run the Script
- In your Worksheet explain how each SCRIPT works.
- Make Changes to the CODE to see what happens
Script #1
#!/bin/bash
# Change this code to your bday if you want
BIRTHDATE="Jan 1, 2000"
Presents=10
BIRTHDAY=`date -d "$BIRTHDATE" +%A`
# Testing code - do not change it
if [ "$BIRTHDATE" == "Jan 1, 2000" ] ; then
echo "BIRTHDATE is correct, it is $BIRTHDATE"
else
echo "BIRTHDATE is incorrect - please retry"
fi
if [ $Presents == 10 ] ; then
echo "I have received $Presents presents"
else
echo "Presents is incorrect - please retry"
fi
if [ "$BIRTHDAY" == "Saturday" ] ; then
echo "I was born on a $BIRTHDAY"
else
echo "BIRTHDAY is incorrect - please retry"
fi
Script #2
#!/bin/bash
NAMES=( John Eric Jessica )
# write your code here
NUMBERS=( 1 2 3 )
STRINGS=( "hello" "world" )
NumberOfNames=${#NAMES[@]}
second_name=${NAMES[1]}
echo ${NUMBERS[@]}
echo ${STRINGS[@]}
echo "The number of names listed in the NAMES array: $NumberOfNames"
echo "The second name on the NAMES list is:" ${second_name}
No comments:
Post a Comment