0

I want to open three terminals and I want to write a command in the first window that will send a Hello message to the other two. The command must allow a one-time sending without a response from the other terminals.

I used:

tee > /dev/pts/1 /dev/pts/2

and everything is good, but I want to exit the command after typing Hello without using Ctrl+d

4
  • 3
    Ctrl+C? It's unclear what the issue is with marking end-of-input with Ctrl+D and it's unclear what you would like to do otherwise. Commented Dec 30, 2022 at 7:05
  • It seems you only want to enter one input, something like read val; echo "$val" | tee /dev/pts/1 /dev/pts/2 perhaps? (or shorter read val; echo "$val" | tee /dev/pts/{1,3}) Commented Dec 30, 2022 at 7:14
  • 1
    Also: head -1 | tee /dev/pts/{1,3} Commented Dec 30, 2022 at 8:19
  • echo Hello | tee … Commented Jan 1, 2023 at 1:15

1 Answer 1

1

To exit, tee needs an end-of-file. If you type normally, Ctrl+d provides this end-of-file. There are other ways:

echo "Hello" |tee > /dev/pts/1 /dev/pts/2 

provides the EOF after the "Hello".

head -1 |tee > /dev/pts/1 /dev/pts/2

provides the EOF after the first line.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.