mirror of
https://github.com/tldr-pages/tldr.git
synced 2025-04-29 23:24:55 +02:00
awk: add operators match (#4606)
This commit is contained in:
parent
3babbbc15b
commit
d78a7103fe
2 changed files with 16 additions and 8 deletions
|
@ -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)'`
|
||||
|
|
|
@ -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)'`
|
||||
|
|
Loading…
Add table
Reference in a new issue