Skip to content
Snippets Groups Projects
Commit 830bbc65 authored by alexis.dereeper_ird.fr's avatar alexis.dereeper_ird.fr
Browse files

Update bash-extracting_from_files.md

parent c16d030f
No related branches found
No related tags found
No related merge requests found
Pipeline #39806 passed
......@@ -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/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment