Skip to content

Commit d96c280

Browse files
sort-uniq-head-tail exercises complete
1 parent 0912ee8 commit d96c280

File tree

7 files changed

+11
-0
lines changed

7 files changed

+11
-0
lines changed

shell-pipelines/sort-uniq-head-tail/script-01.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,6 @@ set -euo pipefail
44

55
# The input for this script is the scores-table.txt file.
66
# TODO: Write a command to output scores-table.txt, with lines sorted by the person's name.
7+
sort scores-table.txt
8+
79
# The first line of your output should be "Ahmed London 1 10 4" (with no quotes). And the third line should be "Chandra Birmingham 12 6".

shell-pipelines/sort-uniq-head-tail/script-02.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ set -euo pipefail
44

55
# The input for this script is the scores-table.txt file.
66
# TODO: Write a command to output scores-table.txt, with lines sorted by the person's first score, descending.
7+
sort -k3nr scores-table.txt
78
# The first line of your output should be "Basia London 22 9 6" (with no quotes).

shell-pipelines/sort-uniq-head-tail/script-03.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ set -euo pipefail
44

55
# The input for this script is the scores-table.txt file.
66
# TODO: Write a command to output scores-table.txt, with shows the lines for the three players with the highest first score, in descending order.
7+
sort -k3nr scores-table.txt | head -n3
8+
79
# Your output should be:
810
# Basia London 22 9 6
911
# Piotr Glasgow 15 2 25 11 8

shell-pipelines/sort-uniq-head-tail/script-04.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ set -euo pipefail
44

55
# The input for this script is the scores-table.txt file.
66
# TODO: Write a command to output scores-table.txt, with shows the line for the player whose first score was the second highest.
7+
sort -k3nr scores-table.txt | head -n2 | tail -n1
78
# Your output should be: "Piotr Glasgow 15 2 25 11 8" (without quotes).

shell-pipelines/sort-uniq-head-tail/script-05.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ set -euo pipefail
44

55
# The input for this script is the events.txt file.
66
# TODO: Write a command to show a list of all events that have happened, without duplication.
7+
sort events.txt | uniq
78
# The order they're displayed doesn't matter, but we never want to see the same event listed twice.
89
# Your output should contain 6 lines.

shell-pipelines/sort-uniq-head-tail/script-06.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,6 @@ set -euo pipefail
44

55
# The input for this script is the events.txt file.
66
# TODO: Write a command to show how many times anyone has entered and exited.
7+
awk '{print $1}' events.txt | sort | uniq -c
8+
79
# It should be clear from your script's output that there have been 5 Entry events and 4 Exit events.

shell-pipelines/sort-uniq-head-tail/script-07.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,7 @@ set -euo pipefail
44

55
# The input for this script is the events-with-timestamps.txt file.
66
# TODO: Write a command to show how many times anyone has entered and exited.
7+
tail -n +2 events-with-timestamps.txt | awk '{print $3}' | sort | uniq -c
8+
79
# It should be clear from your script's output that there have been 5 Entry events and 4 Exit events.
810
# The word "Event" should not appear in your script's output.

0 commit comments

Comments
 (0)