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

Update bash-extracting_from_files.md

parent 830bbc65
No related branches found
No related tags found
No related merge requests found
Pipeline #39809 passed
...@@ -148,22 +148,22 @@ The `cut` command allows to cut a line at a specific character and extract a sel ...@@ -148,22 +148,22 @@ The `cut` command allows to cut a line at a specific character and extract a sel
* `-d` specify the separator * `-d` specify the separator
* `-f` specify the field to extract * `-f` specify the field to extract
!!! question "Combining with `sort` command, how can you extract the name of the top 30 most popular names and the corresponding year" !!! question "Combining with `sort` command, how can you extract the name of the top 50 most popular names and the corresponding year"
??? example "Click to show the solution" ??? example "Click to show the solution"
```bash ```bash
# command # command
sort -n -t ';' -k4 nat2021.csv | tail -n 30 | cut -d";" -f 2,3 sort -n -t ';' -k4 nat2021.csv | tail -n 50 | 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/ The `uniq` command can be used to remove the redundancy. But result need to be sorted to make it work properly/
!!! question "Could you now find a way to filter the redundancy" !!! question "Using `uniq`, could you now find a way to filter the redundancy by keeping only the names"
??? example "Click to show the solution" ??? example "Click to show the solution"
```bash ```bash
# command # command
sort -n -t ';' -k4 nat2021.csv | tail -n 100 | cut -d";" -f 2 | sort | uniq sort -n -t ';' -k4 nat2021.csv | tail -n 50 | cut -d";" -f 2 | sort | uniq
``` ```
!!! question "How many time the name JEAN has been provided in total?" !!! question "How many time the name JEAN has been provided in total?"
......
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