os:filters
Return to Home page
If you found any error, or if you want to partecipate to the editing of this wiki, please contact: admin [at] skenz.it
You can reuse, distribute or modify the content of this page, but you must cite in any document (or webpage) this url: https://www.skenz.it/os/filters?do=diff
no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
— | os:filters [2024/04/08 22:35] (current) – created - external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Filters ====== | ||
+ | Return to [[os: | ||
+ | Examples about filters, i.e., commands '' | ||
+ | |||
+ | |||
+ | ===== Example files ===== | ||
+ | |||
+ | <code txt example.txt> | ||
+ | 408 Rossi Giulia 30.0 | ||
+ | 12 Rossi Stefania 21.5 | ||
+ | 234 Bianchi Gianna 17.0 | ||
+ | 123 Bianchi Bianchi 30.0 | ||
+ | </ | ||
+ | |||
+ | <code txt example_uniq.txt> | ||
+ | Gabriele | ||
+ | Giulia | ||
+ | Stefano | ||
+ | Stefano | ||
+ | Stefano S | ||
+ | Stefania | ||
+ | </ | ||
+ | |||
+ | |||
+ | ===== '' | ||
+ | |||
+ | <code bash> | ||
+ | > cut -d ' ' -f 1,4 example.txt | ||
+ | 12 21.5 | ||
+ | 408 30.0 | ||
+ | 234 17.0 | ||
+ | 123 30.0 | ||
+ | </ | ||
+ | |||
+ | <code bash> | ||
+ | > cut -d ' ' -f 1-2,4 example.txt | ||
+ | 12 Rossi 21.5 | ||
+ | 408 Rossi 30.0 | ||
+ | 234 Bianchi 17.0 | ||
+ | 123 Bianchi 30.0 | ||
+ | </ | ||
+ | |||
+ | ===== '' | ||
+ | |||
+ | <code bash> | ||
+ | > tr -s sn < example.txt | ||
+ | 408 Rosi Giulia 30.0 | ||
+ | 12 Rosi Stefania 21.5 | ||
+ | 234 Bianchi Giana 17.0 | ||
+ | 123 Bianchi Bianchi 30.0 | ||
+ | </ | ||
+ | |||
+ | <code bash> | ||
+ | > tr -d si < example.txt | ||
+ | 408 Ro Gula 30.0 | ||
+ | 12 Ro Stefana 21.5 | ||
+ | 234 Banch Ganna 17.0 | ||
+ | 123 Banch Banch 30.0 | ||
+ | </ | ||
+ | |||
+ | * Replace everything that is **not** the letter '' | ||
+ | <code bash> | ||
+ | > echo "hello world" | tr -c l X | ||
+ | XXllXXXXXlXX | ||
+ | </ | ||
+ | |||
+ | * Replace everything that is **not** a digit with the character '' | ||
+ | <code bash> | ||
+ | > echo " | ||
+ | --------123--------345- | ||
+ | </ | ||
+ | |||
+ | ===== '' | ||
+ | |||
+ | <code bash> | ||
+ | > uniq example_uniq.txt | ||
+ | Gabriele | ||
+ | Giulia | ||
+ | Stefano | ||
+ | Stefano S | ||
+ | Stefania | ||
+ | </ | ||
+ | |||
+ | <code bash> | ||
+ | > uniq -c example_uniq.txt | ||
+ | 1 Gabriele | ||
+ | 1 Giulia | ||
+ | 2 Stefano | ||
+ | 1 Stefano S | ||
+ | 1 Stefania | ||
+ | </ | ||
+ | |||
+ | <code bash> | ||
+ | > uniq -d example_uniq.txt | ||
+ | Stefano | ||
+ | </ | ||
+ | |||
+ | ===== '' | ||
+ | |||
+ | <code bash> | ||
+ | > sort -k1,1n example.txt | ||
+ | 12 Rossi Stefania 21.5 | ||
+ | 123 Bianchi Bianchi 30.0 | ||
+ | 234 Bianchi Gianna 17.0 | ||
+ | 408 Rossi Giulia 30.0 | ||
+ | </ | ||
+ | |||
+ | <code bash> | ||
+ | > sort -k2,2 example.txt | ||
+ | 123 Bianchi Bianchi 30.0 | ||
+ | 234 Bianchi Gianna 17.0 | ||
+ | 12 Rossi Stefania 21.5 | ||
+ | 408 Rossi Giulia 30.0 | ||
+ | </ | ||
+ | |||
+ | <code bash> | ||
+ | > sort -k2,2 -k4,4n example.txt | ||
+ | 234 Bianchi Gianna 17.0 | ||
+ | 123 Bianchi Bianchi 30.0 | ||
+ | 12 Rossi Stefania 21.5 | ||
+ | 408 Rossi Giulia 30.0 | ||
+ | </ | ||
+ | |||
+ | <code bash> | ||
+ | > sort -R example.txt | ||
+ | 234 Bianchi Gianna 17.0 | ||
+ | 123 Bianchi Bianchi 30.0 | ||
+ | 12 Rossi Stefania 21.5 | ||
+ | 408 Rossi Giulia 30.0 | ||
+ | </ | ||
+ | |||
+ | ===== '' | ||
+ | |||
+ | (the '' | ||
+ | |||
+ | <code bash> | ||
+ | > egrep -e " | ||
+ | 408 Rossi Giulia 30.0 | ||
+ | 12 Rossi Stefania 21.5 | ||
+ | 234 Bianchi Gianna 17.0 | ||
+ | </ | ||
+ | |||
+ | <code bash> | ||
+ | > egrep -e " | ||
+ | 408 Rossi Giulia 30.0 | ||
+ | 12 Rossi Stefania 21.5 | ||
+ | 234 Bianchi Gianna 17.0 | ||
+ | </ | ||
+ | |||
+ | <code bash> | ||
+ | > egrep -n -e " | ||
+ | 3:234 Bianchi Gianna 17.0 | ||
+ | 4:123 Bianchi Bianchi 30.0 | ||
+ | </ | ||
+ | |||
+ | <code bash> | ||
+ | > egrep -n -v -e " | ||
+ | 1:408 Rossi Giulia 30.0 | ||
+ | 2:12 Rossi Stefania 21.5 | ||
+ | </ | ||
+ | |||
+ | <code bash> | ||
+ | > egrep -H -A 1 -B 0 -e " | ||
+ | example.txt: | ||
+ | example.txt-234 Bianchi Gianna 17.0 | ||
+ | </ | ||
+ | |||
+ | <code bash> | ||
+ | > egrep -e " | ||
+ | 408 Rossi 30.0 | ||
+ | 12 Rossi 21.5 | ||
+ | 123 Bianchi 30.0 | ||
+ | </ |
If you found any error, or if you want to partecipate to the editing of this wiki, please contact: admin [at] skenz.it
You can reuse, distribute or modify the content of this page, but you must cite in any document (or webpage) this url: https://www.skenz.it/os/filters?do=diff
/web/htdocs/www.skenz.it/home/data/pages/os/filters.txt · Last modified: 2024/04/08 22:35 by 127.0.0.1