0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

trコマンド

Posted at

trコマンドとは?

trコマンドとは、文字の変換や削除をするためのコマンドです。

usage.tr
tr [option] [元の文字列] [変換後の文字列]
option 説明
-d 元の文字列で指定した文字列を削除する(この場合[変換後の文字列]は必要ない)
-s 連続している同じ文字の文字列を一文字にまとめる
example.tr
$tr -d abc
abcdefg <-入力を求められる
defg
$ls 
dir1 dir2
$cat dir1
iiiiiiiiiiiiiiii ABC xyz.
$cat dir1 | tr 'a-z' 'A-Z' | tr -s i //aからzの小文字を大文字に変換する。 i を一つにする。
I ABC XYZ
$cat dir1 | tr ABC xyz | tr -d i //ABCをxyzに変換。 iを削除する。
xyz xyz
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?