diff --git a/certificates/essentials/lpi_essentials_lesson_03.md b/certificates/essentials/lpi_essentials_lesson_03.md index 747942d..014c689 100644 --- a/certificates/essentials/lpi_essentials_lesson_03.md +++ b/certificates/essentials/lpi_essentials_lesson_03.md @@ -125,42 +125,45 @@ fi ## Guided Exercises 1. Read the contents of script1.sh below: -``` -#!/bin/bash -if [ $# -lt 1 ] -then - echo "This script requires at least 1 argument." - exit 1 -fi + ``` + #!/bin/bash + + if [ $# -lt 1 ] + then + echo "This script requires at least 1 argument." + exit 1 + fi + + echo $1 | grep "^[A-Z]*$" > /dev/null + if [ $? -ne 0 ] + then + echo "no cake for you!" + exit 2 + fi + + echo "here's your cake!" + exit 0 + ``` -echo $1 | grep "^[A-Z]*$" > /dev/null -if [ $? -ne 0 ] -then - echo "no cake for you!" - exit 2 -fi - -echo "here's your cake!" -exit 0 -``` * What is the output of these commands? - ``` -./script1.sh -echo $? -./script1.sh cake -echo $? -./script1.sh CAKE -echo $? ``` + ./script1.sh + echo $? + ./script1.sh cake + echo $? + ./script1.sh CAKE + echo $? + ``` + 2. Read the contents of file script2.sh: -``` -for filename in $1/*.txt -do - cp $filename $filename.bak -done -``` + ``` + for filename in $1/*.txt + do + cp $filename $filename.bak + done + ``` * Describe the purpose of this script as you understand it. ## Explorational Exercises