0
0
Bash Scriptingscripting~10 mins

Running scripts in Bash Scripting - Interactive Code Practice

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

Complete the code to run a script named myscript.sh in the current directory.

Bash Scripting
./[1]
Drag options to blanks, or click blank then click option'
Astart.sh
Bmyscript.sh
Cscript.sh
Drun.sh
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting to use ./ before the script name.
Using the wrong script file name.
2fill in blank
medium

Complete the command to make the script myscript.sh executable.

Bash Scripting
chmod [1] myscript.sh
Drag options to blanks, or click blank then click option'
A+x
Brwx
C-x
D777
Attempts:
3 left
💡 Hint
Common Mistakes
Using chmod rwx which sets permissions but not correctly.
Using chmod -x which removes execute permission.
3fill in blank
hard

Fix the error in the command to run myscript.sh with bash explicitly.

Bash Scripting
bash [1]
Drag options to blanks, or click blank then click option'
A./myscript
Bmyscript
C./myscript.sh
Dmyscript.sh
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting ./ causing 'file not found' error.
Using script name without extension.
4fill in blank
hard

Fill both blanks to create a script that prints 'Hello' and then exits with status 0.

Bash Scripting
#!/bin/bash
 echo [1]
 exit [2]
Drag options to blanks, or click blank then click option'
A"Hello"
B0
C1
D'Hello'
Attempts:
3 left
💡 Hint
Common Mistakes
Not quoting the string, causing errors.
Using exit status other than 0 for success.
5fill in blank
hard

Fill all three blanks to create a script that takes one argument and prints it.

Bash Scripting
#!/bin/bash
 input=[1]
 echo [2]
 exit [3]
Drag options to blanks, or click blank then click option'
A$1
B$input
C0
D$0
Attempts:
3 left
💡 Hint
Common Mistakes
Using $0 which is the script name, not the argument.
Not exiting with 0 to indicate success.