0
0
Bash Scriptingscripting~10 mins

Environment variables vs local variables in Bash Scripting - Interactive Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to set a local variable named name with the value John.

Bash Scripting
name=[1]
Drag options to blanks, or click blank then click option'
AJohn
B'John'
C"John"
Dname
Attempts:
3 left
💡 Hint
Common Mistakes
Using quotes unnecessarily when not needed
Trying to export the variable when only local is needed
2fill in blank
medium

Complete the code to export a variable PATH with the value /usr/bin so it becomes an environment variable.

Bash Scripting
export PATH=[1]
Drag options to blanks, or click blank then click option'
APATH
B/usr/bin
C"/usr/bin"
D'/usr/bin'
Attempts:
3 left
💡 Hint
Common Mistakes
Not using quotes causing errors if path contains spaces
Assigning without export so variable is local only
3fill in blank
hard

Fix the error in the code to correctly print the value of the environment variable HOME.

Bash Scripting
echo [1]
Drag options to blanks, or click blank then click option'
A$HOME
BHOME
C${HOME}
Denv HOME
Attempts:
3 left
💡 Hint
Common Mistakes
Printing the variable name without $ so it prints the literal string
Using env HOME which is incorrect syntax
4fill in blank
hard

Fill both blanks to create a local variable var with value 5 and export it as an environment variable.

Bash Scripting
var=[1]
[2] var
Drag options to blanks, or click blank then click option'
A5
Bexport
Cset
Ddeclare
Attempts:
3 left
💡 Hint
Common Mistakes
Using set or declare instead of export
Putting quotes around the number 5
5fill in blank
hard

Fill all three blanks to create a local variable count with value 10, export it, and then print its value.

Bash Scripting
count=[1]
[2] count
[3] $count
Drag options to blanks, or click blank then click option'
A10
Bexport
Cecho
Dprint
Attempts:
3 left
💡 Hint
Common Mistakes
Using print instead of echo
Not exporting the variable before printing
Putting quotes around the number 10