Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to sort the lines of a file named 'data.txt'.
Bash Scripting
sort [1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using options like -r or -u instead of the filename.
Typing the wrong filename.
✗ Incorrect
The 'sort' command followed by the filename 'data.txt' sorts the lines in that file.
2fill in blank
mediumComplete the pipeline to sort the output of 'cat data.txt' and remove duplicate lines.
Bash Scripting
cat data.txt | sort | [1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'grep' or 'wc' instead of 'uniq'.
Not sorting before using 'uniq'.
✗ Incorrect
The 'uniq' command removes duplicate lines from sorted input.
3fill in blank
hardFix the error in the pipeline that tries to remove duplicates but does not sort first.
Bash Scripting
cat data.txt | [1] | uniq Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'grep' or 'head' instead of 'sort'.
Not sorting before 'uniq'.
✗ Incorrect
The 'uniq' command only removes adjacent duplicates, so sorting first is necessary.
4fill in blank
hardFill both blanks to create a pipeline that sorts 'data.txt' in reverse order and removes duplicates.
Bash Scripting
cat data.txt | sort [1] | uniq [2]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-c' or '-d' with 'uniq' instead of '-u'.
Not using '-r' to reverse sort.
✗ Incorrect
The '-r' option sorts in reverse order, and '-u' makes 'uniq' output unique lines only.
5fill in blank
hardFill all three blanks to create a pipeline that counts how many times each unique line appears in 'data.txt', sorted by count descending.
Bash Scripting
cat data.txt | sort | uniq [1] | sort [2] -k1,1n | sort [3] -k1,1nr
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Not using '-c' with 'uniq' to count.
Wrong sort options or missing reverse sort.
✗ Incorrect
The '-c' option counts duplicates, '-k' specifies sort key, and '-r' sorts in reverse order for descending counts.