While looking for a way to add the same text ‘text1’ to the end of multiple files using the tee command, I stumbled upon a strange “side effect.” At least, that’s how I see it, but I might be completely wrong.
The standard command to perform this operation is probably echo <text1> | tee -a <files>. I tried this command:
echo "text1" > >(tee -a <files>).
Here’s an example of what appeared in the terminal, where g* represents existing files:
:~$ echo 'text1' > >(tee -a g*)
:~$ text1
[an empty line]
I had to use Ctrl + C to end the process and get a new prompt.
Since I couldn’t find any explanation, I asked DuckDuck AI. Here’s its response:
Because process substitution runs asynchronously, the shell can show
the next prompt before tee prints “text1”, making it look like a
second prompt appeared.
To check whether this second prompt was a real one, I did this:
~$ echo 'text1' > >(tee -a g*)
~$ text1
ls -a
[a list of all my /home/ files and directories was displayed]
~$
Does the AI’s response seem plausible to you? Could you suggest another test to validate or invalidate this response?