From c86216e2612ba236816a5210e50aaa27ef0cad0a Mon Sep 17 00:00:00 2001 From: Daniel Senff Date: Thu, 12 Mar 2015 09:41:54 +0100 Subject: [PATCH 1/3] Create tr.md tr is a small utility for translating characters in text documents --- pages/common/tr.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 pages/common/tr.md diff --git a/pages/common/tr.md b/pages/common/tr.md new file mode 100644 index 0000000000..423d1ba65e --- /dev/null +++ b/pages/common/tr.md @@ -0,0 +1,15 @@ +# tr + +> translate characters - run replacements based on single characters + +- replace all occurrences of a character in a file, and print the result + +`tr {{find_character}} {{replace_character}} < {{filename}}` + + Translate the contents of the file to upper-case, prints result. + +`tr "[:lower:]" "[:upper:]" < {{filename}}` + +Strip out non-printable characters from the file, prints result. + +`tr -cd "[:print:]" < {{filename}}` From 70017a62004c2c2440bda4f209e43e6ac23d6628 Mon Sep 17 00:00:00 2001 From: Daniel Senff Date: Sat, 14 Mar 2015 12:05:19 +0100 Subject: [PATCH 2/3] add more examples to tr These examples were suggested to add and are based from the tr-wikipedia article at https://en.wikipedia.org/w/index.php?title=Tr_(Unix)&oldid=631477596 --- pages/common/tr.md | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/pages/common/tr.md b/pages/common/tr.md index 423d1ba65e..0a1a3fba1e 100644 --- a/pages/common/tr.md +++ b/pages/common/tr.md @@ -1,15 +1,27 @@ # tr -> translate characters - run replacements based on single characters +> translate characters - run replacements based on single characters and character sets -- replace all occurrences of a character in a file, and print the result +- Replace all occurrences of a character in a file, and prints the result -`tr {{find_character}} {{replace_character}} < {{filename}}` +`tr {{find_characters}} {{replace_characters}} < {{filename}}` - Translate the contents of the file to upper-case, prints result. +- Maps each character of the first set to the corresponding character of the second set. + +`tr 'abcd' 'jkmn' < {{filename}}` + +- Delete all occurances of the specified set of characters from the input. + +`tr -d '{{input_characters}}'` + +- Compresses a series of identical characters to a single character. + +`tr -s '\n'` + +- Translate the contents of the file to upper-case, prints result. `tr "[:lower:]" "[:upper:]" < {{filename}}` -Strip out non-printable characters from the file, prints result. +- Strip out non-printable characters from the file, prints result. `tr -cd "[:print:]" < {{filename}}` From 7f48d18e12cdc336cac7d8f398697a180016b23e Mon Sep 17 00:00:00 2001 From: Daniel Senff Date: Sat, 14 Mar 2015 16:34:38 +0100 Subject: [PATCH 3/3] common verb conjugation for all tr command descriptions --- pages/common/tr.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pages/common/tr.md b/pages/common/tr.md index 0a1a3fba1e..6e2317e6f6 100644 --- a/pages/common/tr.md +++ b/pages/common/tr.md @@ -2,11 +2,11 @@ > translate characters - run replacements based on single characters and character sets -- Replace all occurrences of a character in a file, and prints the result +- Replace all occurrences of a character in a file, and print the result `tr {{find_characters}} {{replace_characters}} < {{filename}}` -- Maps each character of the first set to the corresponding character of the second set. +- Map each character of the first set to the corresponding character of the second set. `tr 'abcd' 'jkmn' < {{filename}}` @@ -14,14 +14,14 @@ `tr -d '{{input_characters}}'` -- Compresses a series of identical characters to a single character. +- Compress a series of identical characters to a single character. `tr -s '\n'` -- Translate the contents of the file to upper-case, prints result. +- Translate the contents of the file to upper-case and print result. `tr "[:lower:]" "[:upper:]" < {{filename}}` -- Strip out non-printable characters from the file, prints result. +- Strip out non-printable characters from the file and print result. `tr -cd "[:print:]" < {{filename}}`