From 85787f42af9d1f6b8bbfcee89eceac375b56b6e2 Mon Sep 17 00:00:00 2001 From: "alexis.dereeper_ird.fr" <alexis.dereeper@ird.fr> Date: Sat, 23 Nov 2024 15:23:41 +0000 Subject: [PATCH] Update bash-extracting_from_files.md --- docs/pages/bash/bash-extracting_from_files.md | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/docs/pages/bash/bash-extracting_from_files.md b/docs/pages/bash/bash-extracting_from_files.md index dddabbf..fc50c82 100644 --- a/docs/pages/bash/bash-extracting_from_files.md +++ b/docs/pages/bash/bash-extracting_from_files.md @@ -166,11 +166,6 @@ The `uniq` command can be used to remove the redundancy. But result need to be s 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?" - -??? example "Click to show the solution" - It start to be too complicated for the command you have seen so far, you need to use a command specific to column data `awk` - ## Redirecting an output (>) @@ -206,4 +201,12 @@ You can redirect a result and store it in a file thanks to the `>` redirection: ``` -## Filtering a file (awk) \ No newline at end of file +## Filtering a file (awk) + +!!! question "Using `awk` on tabular file, display the most popular names (given more than 10000 times) between 1980 and 1990" + +??? example "Click to show the solution" + ```bash + awk {'if ($3 >= 1980 && $3 <= 1990 && $4 > 10000)print $1'} nat2021.tsv + ``` + -- GitLab