diff --git a/certificates/essentials/lpi_essentials_lesson_03.md b/certificates/essentials/lpi_essentials_lesson_03.md index 014c689..b00712b 100644 --- a/certificates/essentials/lpi_essentials_lesson_03.md +++ b/certificates/essentials/lpi_essentials_lesson_03.md @@ -73,49 +73,49 @@ # Lesson 3.3.1 1. The user types the following to their shell: -``` -$ PATH=~/scripts -$ ls -Command 'ls' is available in '/bin/ls' -The command could not be located because '/bin' is not included in the PATH environment variable. -ls: command not found -``` + ``` + $ PATH=~/scripts + $ ls + Command 'ls' is available in '/bin/ls' + The command could not be located because '/bin' is not included in the PATH environment variable. + ls: command not found + ``` * What has the user done? * What command will combine the current value of PATH with the new directory ~/scripts? 1. Consider the following script. Notice that it is using elif to check for a second condition: -``` -> /!bin/bash - -> fruit1 = Apples -> fruit2 = Oranges - - if [ $1 -lt $# ] - then - echo "This is like comparing $fruit1 and $fruit2!" -> elif [$1 -gt $2 ] - then -> echo '$fruit1 win!' - else -> echo "Fruit2 win!" -> done -``` + ``` + > /!bin/bash + + > fruit1 = Apples + > fruit2 = Oranges + + if [ $1 -lt $# ] + then + echo "This is like comparing $fruit1 and $fruit2!" + > elif [$1 -gt $2 ] + then + > echo '$fruit1 win!' + else + > echo "Fruit2 win!" + > done + ``` * The lines marked with a > contain errors. Fix the errors. 1. What will the output be in the following situations? -``` -$ ./guided1.sh 3 0 -$ ./guided1.sh 2 4 -$ ./guided1.sh 0 1 -``` + ``` + $ ./guided1.sh 3 0 + $ ./guided1.sh 2 4 + $ ./guided1.sh 0 1 + ``` ## Explorational Exercises 1. Write a simple script that will check if exactly two arguments are passed. If so, print the arguments in reverse order. Consider this example (note: your code may look different than this, but should lead to the same output): -``` -if [ $1 == $number ] -then - echo "True!" -fi -``` + ``` + if [ $1 == $number ] + then + echo "True!" + fi + ``` 1. This code is correct, but it is not a number comparison. Use an internet search to discover how this code is different from using -eq. 1. There is an environment variable that will print the current directory. Use env to discover the name of this variable. 1. Using what you have learned in questions 2 and 3, write a short script that accepts an argument. If an argument is passed, check if that argument matches the name of the current directory. If so, print yes. Otherwise, print no. @@ -125,7 +125,6 @@ fi ## Guided Exercises 1. Read the contents of script1.sh below: - ``` #!/bin/bash @@ -145,9 +144,7 @@ fi echo "here's your cake!" exit 0 ``` - * What is the output of these commands? - ``` ./script1.sh echo $?