[Overview]tr Examples
tr - translate or delete characters
tr [OPTION]... SET1 [SET2]
-c: use the complement of SET1
-d: delete characters in SET1, do not translate
-s: replace each input sequence of a repeated character that is listed
in SET1 with a single occurrence of that character
for further information see the manual page tr(1)
- change text to lowercase
tr 'A-Z' 'a-z' < ../data/moby-dick.txt
[Output]
- shift-5 caesars cipher algo encoding
echo "this simulates a simple caesars chiper algo" | tr 'A-Za-z' 'F-ZA-Ef-za-e'
[Output]
- shift-5 caesars cipher algo encode and decode
echo "this simulates a simple caesars chiper algo" | tr 'A-Za-z' 'F-ZA-Ef-za-e' | tr 'F-ZA-Ef-za-e' 'A-Za-z'
[Output]
- extracts all words from the book (each word in a line)
tr -c -s '[:alpha:]' ' ' < ../data/moby-dick.txt | tr ' ' '\n'
[Output]
- delete all quotes (") from the input
tr -d '"' < ../data/city.sample.csv
[Output]
- remove all linebreaks
tr '\n' ' ' < ../data/moby-dick.txt
[Output]
all examples assembled by andreas schmidt for the IC3K 2022 conference