2015-03-12 08:41:54 +00:00
|
|
|
# tr
|
|
|
|
|
2015-03-14 11:05:19 +00:00
|
|
|
> translate characters - run replacements based on single characters and character sets
|
2015-03-12 08:41:54 +00:00
|
|
|
|
2015-03-14 15:34:38 +00:00
|
|
|
- Replace all occurrences of a character in a file, and print the result
|
2015-03-12 08:41:54 +00:00
|
|
|
|
2015-03-14 11:05:19 +00:00
|
|
|
`tr {{find_characters}} {{replace_characters}} < {{filename}}`
|
2015-03-12 08:41:54 +00:00
|
|
|
|
2015-03-14 15:34:38 +00:00
|
|
|
- Map each character of the first set to the corresponding character of the second set.
|
2015-03-14 11:05:19 +00:00
|
|
|
|
|
|
|
`tr 'abcd' 'jkmn' < {{filename}}`
|
|
|
|
|
|
|
|
- Delete all occurances of the specified set of characters from the input.
|
|
|
|
|
|
|
|
`tr -d '{{input_characters}}'`
|
|
|
|
|
2015-03-14 15:34:38 +00:00
|
|
|
- Compress a series of identical characters to a single character.
|
2015-03-14 11:05:19 +00:00
|
|
|
|
|
|
|
`tr -s '\n'`
|
|
|
|
|
2015-03-14 15:34:38 +00:00
|
|
|
- Translate the contents of the file to upper-case and print result.
|
2015-03-12 08:41:54 +00:00
|
|
|
|
|
|
|
`tr "[:lower:]" "[:upper:]" < {{filename}}`
|
|
|
|
|
2015-03-14 15:34:38 +00:00
|
|
|
- Strip out non-printable characters from the file and print result.
|
2015-03-12 08:41:54 +00:00
|
|
|
|
|
|
|
`tr -cd "[:print:]" < {{filename}}`
|