【LPIC】trコマンドの使い方【標準入力したものを変換して出力する】
![thumbnail](https://noauto-nolife.com/images/lpic.jpg)
trコマンドは標準入力したものを変換して出力することができる。
例えば、以下のようにhelloをHelloに変換する
tr "hello" "Hello"
# tr hello Hello でも可
![](/images/Screenshot from 2023-03-11 15-21-07.png)
テキストファイルに書かれてある内容を置換して出力することができる。
tr hello Hello < test.txt
![](/images/Screenshot from 2023-03-11 15-02-18.png)
置換した内容を別のテキストファイルにリダイレクトして書き込みできる。
tr hello Hello < test.txt > test2.txt
![](/images/Screenshot from 2023-03-11 15-24-52.png)
ちなみに、このように同じテキストにリダイレクトして書き込みしようとすると、このように全て消える。
tr hello Hello < test.txt > test.txt
![](/images/Screenshot from 2023-03-11 15-27-35.png)