0
0
Bash Scriptingscripting~10 mins

Prompting with read -p 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 prompt the user for their name and store it in the variable.

Bash Scripting
read [1]
Drag options to blanks, or click blank then click option'
A-p 'Enter your name: ' name
B-p name
C-p 'Enter your name: '
D-n 'Enter your name: '
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting to include the variable name after the prompt.
Using '-n' instead of '-p' for prompting.
2fill in blank
medium

Complete the code to prompt the user for their age and store it in the variable 'age'.

Bash Scripting
read [1] age
Drag options to blanks, or click blank then click option'
A-n 'Enter your age: '
B-s 'Enter your age: '
C-p 'Enter your age: '
D-r 'Enter your age: '
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-n' which limits the number of characters read instead of prompting.
Using '-s' which hides input (used for passwords).
3fill in blank
hard

Fix the error in the code to correctly prompt for a password without showing input.

Bash Scripting
read [1] password
Drag options to blanks, or click blank then click option'
A-p 'Enter password: '
B-n 'Enter password: '
C-r 'Enter password: '
D-s -p 'Enter password: '
Attempts:
3 left
💡 Hint
Common Mistakes
Using only '-p' which shows input.
Using '-n' which limits input length instead of hiding input.
4fill in blank
hard

Fill both blanks to prompt the user for their favorite color and store it in 'color'.

Bash Scripting
read [1] [2]
Drag options to blanks, or click blank then click option'
A-p 'What is your favorite color? '
B-s
Ccolor
Danswer
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-s' which hides input when not needed.
Using wrong variable names.
5fill in blank
hard

Fill all three blanks to prompt for username and password, hiding password input.

Bash Scripting
read [1] username
read [2] [3]
Drag options to blanks, or click blank then click option'
A-p 'Enter username: '
B-s -p 'Enter password: '
Cpassword
D-p 'Enter password: '
Attempts:
3 left
💡 Hint
Common Mistakes
Not hiding password input.
Forgetting to specify variable names.