A Linux Puzzle using tr command

Joined
Apr 16, 2023
Messages
149
Reaction score
16
Credits
1,460
Code:
cat greeting
 hello

Code:
cat greeting | tr -d "\r"
hello world

Create a file called greeting so that you can generate the expected output as shown in second case.
 


Code:
cat greeting
 hello

Code:
cat greeting | tr -d "\r"
hello world

Create a file called greeting so that you can generate the expected output as shown in second case.

Code:
echo "hello world" >/tmp/greeting
cat /tmp/greeting |tr -d "\r"
hello world

But I feel like I'm missing something... since a system using unix-style newlines doesn't produce carriage returns without them being explicitly included, the pipe into the "tr" command doesn't really have anything to do...

Code:
cat /tmp/greeting
hello world
 


Latest posts

Top