diff --git a/docs/pages/bash/bash-extracting_from_files.md b/docs/pages/bash/bash-extracting_from_files.md index 4541a45bb449be3446b70e378d434fbb21c4a55f..2a3f095c5a5198990eb29bc894a00f4cc418dfee 100644 --- a/docs/pages/bash/bash-extracting_from_files.md +++ b/docs/pages/bash/bash-extracting_from_files.md @@ -115,10 +115,12 @@ Sort is particularly useful when you use some key options: !!! question "Look at the first lines after sorting numerically. Do you observe any difference?" -```bash -sort nat2021.csv | head -sort -n nat2021.csv | head -``` +??? example "Click to show the solution" + + ```bash + sort nat2021.csv | head + sort -n nat2021.csv | head + ``` !!! question "Which name was the most popular among all records? Which year?" @@ -146,12 +148,12 @@ The `cut` command allows to cut a line at a specific character and extract a sel * `-d` specify the separator * `-f` specify the field to extract -!!! question "How to extract the name of the top 100 names/year the most provided" +!!! question "Combining with `sort` command, how can you extract the name of the top 30 most popular names and the corresponding year" ??? example "Click to show the solution" ```bash # command - sort -n -t ';' -k4 nat2021.csv | tail -n 100 | cut -d";" -f 2 + sort -n -t ';' -k4 nat2021.csv | tail -n 30 | cut -d";" -f 2,3 ``` The `uniq` command can be used to remove the redundancy. But result need to be sorted to make it work properly/