November 08, 2018

tr(translate or delete characters)


The Linux software used to replace strings.
문자열 치환에 사용되는 리눅스 소프트웨어.





1. Feature  특징
01. The basic software of Linux.
리눅스의 기본 소프트웨어.




2. How to install  설치 방법
01. Don't need to install.
설치할 필요 없음.




3. How to use  사용법

$ cat ./test.txt
The full documentation for tr is maintained as a Texinfo manual.  If the info and tr programs are properly installed at your site, the  command
< The test data >


❑ Changing Lowercase to uppercase.
소문자를 대문자로
$ cat ./test.txt | tr "a-z" "A-Z"
THE FULL DOCUMENTATION FOR TR IS MAINTAINED AS A TEXINFO MANUAL.  IF THE INFO AND TR PROGRAMS ARE PROPERLY INSTALLED AT YOUR SITE, THE  COMMAND
$
$ cat ./test.txt | tr "[a-z]" "[A-Z]"
THE FULL DOCUMENTATION FOR TR IS MAINTAINED AS A TEXINFO MANUAL.  IF THE INFO AND TR PROGRAMS ARE PROPERLY INSTALLED AT YOUR SITE, THE  COMMAND


❑ Deletion
삭제
$ cat ./test.txt | tr -d " "
ThefulldocumentationfortrismaintainedasaTexinfomanual.Iftheinfoandtrprogramsareproperlyinstalledatyoursite,thecommand
$
$ cat ./test.txt | tr -d "a"
The full documenttion for tr is mintined s  Texinfo mnul.  If the info nd tr progrms re properly instlled t your site, the  commnd


❑ Making duplicate values to one.
중복 문자열을 하나로 변경.
$ cat ./test.txt | tr -s "m"
The full documentation for tr is maintained as a Texinfo manual.  If the info and tr programs are properly installed at your site, the  comand


❑ Replacing all non-alphabetic characters with new-line characters.
알파벳이 아닌 글자를 CRLF(\n) 문자열로 변경.
$ cat ./test.txt | tr -c "a-zA-Z" "\n"
The
full
documentation
for
tr
is
maintained
as
a
Texinfo
manual


If
the
info
and
tr
programs
are
properly
installed
at
your
site

the

command


❑ Creating a Caesar cipher(ROT13)
카이사르 암호문 만들기(ROT13).
$ cat ./test.txt | tr "A-Za-z" "N-ZA-Mn-za-m"
Gur shyy qbphzragngvba sbe ge vf znvagnvarq nf n Grkvasb znahny.  Vs gur vasb naq ge cebtenzf ner cebcreyl vafgnyyrq ng lbhe fvgr, gur  pbzznaq
$
$ cat ./test.txt | tr "A-Za-z" "N-ZA-Mn-za-m" | tr "A-Za-z" "N-ZA-Mn-za-m"
The full documentation for tr is maintained as a Texinfo manual.  If the info and tr programs are properly installed at your site, the  command


Check environment
O    S Windws 7 (64bit) CPU Intel i7
RAM 8 GB SHELL Bash 4.4.12(3)(Cygwin)