0
0
Bash Scriptingscripting~10 mins

Here strings (<<<) 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 use a here string to pass the word 'hello' to the 'cat' command.

Bash Scripting
cat [1] 'hello'
Drag options to blanks, or click blank then click option'
A<<<
B<
C<<
D>>
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<<' which is for here documents, not here strings.
Using '<' which reads from a file, not a string.
2fill in blank
medium

Complete the code to count the number of words in the string 'one two three' using a here string.

Bash Scripting
wc -w [1] 'one two three'
Drag options to blanks, or click blank then click option'
A>>
B<<
C<
D<<<
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' which expects a filename, causing an error.
Using '<<' which expects a delimiter for a here document.
3fill in blank
hard

Fix the error in the code to correctly use a here string to grep the word 'apple' in the string 'apple banana'.

Bash Scripting
grep apple [1] 'apple banana'
Drag options to blanks, or click blank then click option'
A<<
B<<<
C<
D>>
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' which expects a file, causing an error.
Using '<<' which is for here documents, not here strings.
4fill in blank
hard

Fill all blanks to create a here string that converts 'hello world' to uppercase using 'tr'.

Bash Scripting
tr [1] [2] [3] 'hello world'
Drag options to blanks, or click blank then click option'
A'[:lower:]'
B'[:upper:]'
C<<<
D<<
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<<' instead of '<<<' for here string.
Swapping the character sets in 'tr'.
5fill in blank
hard

Fill both blanks to create a dictionary of word lengths for words longer than 3 letters using a here string and Python.

Bash Scripting
python3 <<< "words = 'apple banana cat dog'.split()\nlengths = [1]: len([2]) for [2] in words if len({{BLANK_2}) > 3}\nprint(lengths)"
Drag options to blanks, or click blank then click option'
A{word
Bword
C}
Dwords
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'words' instead of 'word' as the loop variable.
Missing closing brace in the dictionary comprehension.