cmdref.net - Cheat Sheet and Example

cmdref.net is command references/cheat sheets/examples for system engineers.

User Tools

Site Tools


Sidebar








Cloud



Etc


Reference














.

os:linux:command:tr.html



Linux Commands : tr

Example

Replace line breaks to a specific character

# cat test.txt
aaaaaaaaa
bbbbbbbbb
ccccccccc
ddddddddd
eeeeeeeee
#
# cat test.txt | tr '\n' ','
aaaaaaaaa,bbbbbbbbb,ccccccccc,ddddddddd,eeeeeeeee,#
#
#

Remove line breaks

# cat test.txt
aaaaaaaaa
bbbbbbbbb
ccccccccc
#
# cat test.txt |tr -d '\n'
aaaaaaaaabbbbbbbbbccccccccc#
#

Convert continuous space to a single space

# cat test1.txt
1  2     3    4     5
a  b     c    d     e
# cat test1.txt |tr -s ' '
1 2 3 4 5
a b c d e
#



os/linux/command/tr.html.txt ยท Last modified: 2017/05/14 by admin

Page Tools