Finding the top most crime in the whole country (sort, tail, awk)
To find the top most crime that happened the highest number of times in Australia, we want to sort
our crimedata-au.csv
file by the Total
column (column 11
).
As mentioned earlier, Bash has a command just for doing that, and as you may have guessed, it’s called sort
. However, running sort on the .csv
will output all lines of the file on the screen! which is not essentially very useful.
Instead, we would like to sort the file, and then only show the first few lines of the sorted result. To do this, we’ll need to use pipes ( | )
as we did before. As a quick reminder, pipes are convenient because they allow you to move the output of a command into the input of another command, without saving the intermediate result to a file.
Get hands-on with 1400+ tech skills courses.