Score:0

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

fo flag

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.

vn flag
Does this answer your question? [What is the difference between "Redirection" and "Pipe"?](https://askubuntu.com/questions/172982/what-is-the-difference-between-redirection-and-pipe). Also, you can, with `echo test | sudo pipe /dev/ttyx`
waltinator avatar
it flag
With `| /dev/ttys010` is NOT an executable program expecting "test" on its `STDIN` I/O stream, it's a device, which needs to be managed by a program. `>/dev/ttys010` connects the device to the `STDOUT` I/O stream of the "`echo`" program. A better explanation is available in `man bash`.
Score:3
in flag

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.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.