Tr: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
(Created page with "=Internal= * Linux =Overview= =To Uppercase= <syntaxhighlight lang='bash'> echo "hi" | tr '[:lower:]' '[:upper:]' </syntaxhighlight>")
 
 
(5 intermediate revisions by the same user not shown)
Line 2: Line 2:


* [[Linux#Commands|Linux]]
* [[Linux#Commands|Linux]]
* [[Bash Trim|bash Trim]]


=Overview=
=Overview=
Translate characters.
=Options=
==<tt>-d</tt>==
Delete from the input the characters specified in the given string.
Example, delete new lines:
<syntaxhighlight lang='bash'>
cat ./test.txt | tr -d \\n
</syntaxhighlight>


=To Uppercase=
=To Uppercase=


Also see [[Bash_Parameter_and_Variable_Expansion#To_Uppercase|bash Parameter and Variable Expansion]].
==First Character==
<syntaxhighlight lang='bash'>
$(echo ${var_name:0:1} | tr '[:lower:]' '[:upper:]')${var_name:1}
</syntaxhighlight>
==All Characters==
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
echo "hi" | tr '[:lower:]' '[:upper:]'
echo "hi" | tr '[:lower:]' '[:upper:]'
</syntaxhighlight>
</syntaxhighlight>

Latest revision as of 01:07, 2 March 2024

Internal

Overview

Translate characters.

Options

-d

Delete from the input the characters specified in the given string.

Example, delete new lines:

cat ./test.txt | tr -d \\n

To Uppercase

Also see bash Parameter and Variable Expansion.

First Character

$(echo ${var_name:0:1} | tr '[:lower:]' '[:upper:]')${var_name:1}

All Characters

echo "hi" | tr '[:lower:]' '[:upper:]'