Skip to content

Commit d5e0460

Browse files
committed
sort-uniq-head-tail
1 parent d90ad44 commit d5e0460

File tree

7 files changed

+9
-0
lines changed

7 files changed

+9
-0
lines changed

shell-pipelines/sort-uniq-head-tail/script-01.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 name.
7+
sort scores-table.txt -k1
78
# 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 scores-table.txt -k3 -n -r
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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ 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 scores-table.txt -k3 -n -r | head -3
78
# Your output should be:
89
# Basia London 22 9 6
910
# 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 scores-table.txt -k3 -n -r | sed -n '2p'
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+
cat events.txt | sort -u
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+
cat events.txt | grep 'Entry' | sort -u | wc -l | sed 's/$/ entries/'
8+
cat events.txt | grep 'Exit' | sort -u | wc -l | sed 's/$/ exits/'
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+
cat events-with-timestamps.txt | grep 'Entry' | sort -u | wc -l | sed 's/$/ entries/'
8+
cat events-with-timestamps.txt | grep 'Exit' | sort -u | wc -l | sed 's/$/ exits/'
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)