Why can I write to /dev/ttys010 using `>` but not `|`

I am trying to play around and understanding ttys.
In one terminal emulator window, the output of tty gives me

$ tty
/dev/ttys010

So I figured if I write to this device, the terminal window will show the output.
In a second window, when I run

$ echo "test" > /dev/ttys010

The first window shows the word "test" as expect. However, when I run

$ echo "test" | /dev/ttys010

I get no output in the first window. Why is this? I assume its because | redirects stdout to programs while > redirects output to files.

You can write to a file with a pipe. Here are two alternatives

echo "test" | tee /dev/ttys010
echo "test" | cat > /dev/ttys010

As explained in the answer in the comment above, pipes feed stdout of one program to stdin of another program, and /dev/ttys010 is a device file, not a program and is generally not something you want to run.

Answered By: user10489
Categories: Answers Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.