0
0
Bash Scriptingscripting~10 mins

sort and uniq in pipelines 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 sort the lines of a file named 'data.txt'.

Bash Scripting
sort [1]
Drag options to blanks, or click blank then click option'
A-r
Bdata.txt
C-u
Ddata.csv
Attempts:
3 left
💡 Hint
Common Mistakes
Using options like -r or -u instead of the filename.
Typing the wrong filename.
2fill in blank
medium

Complete 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'
Agrep
Bhead
Cwc
Duniq
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'grep' or 'wc' instead of 'uniq'.
Not sorting before using 'uniq'.
3fill in blank
hard

Fix 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'
Asort
Bgrep
Chead
Dtail
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'grep' or 'head' instead of 'sort'.
Not sorting before 'uniq'.
4fill in blank
hard

Fill 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'
A-r
B-c
C-d
D-u
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-c' or '-d' with 'uniq' instead of '-u'.
Not using '-r' to reverse sort.
5fill in blank
hard

Fill 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'
A-c
B-k
C-r
D-u
Attempts:
3 left
💡 Hint
Common Mistakes
Not using '-c' with 'uniq' to count.
Wrong sort options or missing reverse sort.