awk: add operators match (#4606)

This commit is contained in:
CARE-COLIN Thibaut 2020-11-01 15:42:00 +01:00 committed by GitHub
parent 3babbbc15b
commit d78a7103fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 8 deletions

View File

@ -26,3 +26,11 @@
- Affiche une ligne sur trois en partant de la première ligne :
`awk 'NR%3==1' {{nom_de_fichier}}`
- Affiche les lignes dont la valeur de la colone 10 vaut la valeur recherchée :
`awk '($10 == valeur)'`
- Affiche les lignes dont la valeur de la colone 10 est comprise entre un min et un max :
`awk '($10 >= valeur_min && $10 <= valeur_max)'`

View File

@ -19,18 +19,18 @@
`awk '{s+=$1} END {print s}' {{filename}}`
- Sum the values in the first column and pretty-print the values and then the total:
`awk '{s+=$1; print $1} END {print "--------"; print s}' {{filename}}`
- Print every third line starting from the first line:
`awk 'NR%3==1' {{filename}}`
- Print all values starting from the third column:
`awk '{for (i=3; i <= NF; i++) printf $i""FS; print""}' {{filename}}`
- Print different values based on conditions:
`awk '{if ($1 == "foo") print "Exact match foo"; else if ($1 ~ "bar") print "Partial match bar"; else print "Baz"}' {{filename}}`
- Print all lines where the 10th column value equals the specified value :
`awk '($10 == value)'`
- Print all the lines which the 10th column value is between a min and a max :
`awk '($10 >= min_value && $10 <= max_value)'`