Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Given the following file: $ cat sections a:section1-01:orange a:section2-02:appl

ID: 3576533 • Letter: G

Question

Given the following file:
$ cat sections
a:section1-01:orange
a:section2-02:apple
a:section3-01:pear
a:section2-03:mengo
b:section1-02:cat
b:section3-01:dog
b:section2-03:horse
c:section3-02:blue
c:section2-01:green
c:section1-01:red
c:section1-02:white

Sort the lines by the second column and then by the third column. The first column is already sorted.

Sort the following file that contains a list of ip addresses:

$ cat ip-addresses
24.172.220.218
41.239.36.19
63.215.202.234
66.176.124.22
78.110.50.139
163.24.136.10
79.143.179.98
83.4.136.214
84.111.37.26
187.41.94.232
187.40.64.252
24.172.220.218
187.45.225.192
189.10.91.21
190.77.158.128
193.34.144.193

Explanation / Answer

1)

The -n option tells sort to sort numerically, and -k2 sets the sort key to the second field.

The -t sets the field delimiter and the -k3 tells sort to sort based on the part of the line starting with the 3rd field

2) Simply sort the IP's

ls -1 | sort

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote