Artificial intelligent assistant

Write to FIFO only if it exists Most of the examples that I see about writing to a FIFO say to use the `echo` or `cat` commands and redirect stdout to the file. E.g., echo 'a' > /tmp/my_fifo However, this will create a regular file if the FIFO does not already exist. Is there some analog to `mkfifo` but for writing that would fail if it doesn't exist? That is, something similar to: echo 'a' | write-to-existing-file /tmp/my_fifo

According to the BASH manual:


-p file
True if file exists and is a named pipe (FIFO).


So:


if [[ -p /tmp/my_fifo ]]; then
# commands to execute
fi


The question has the tag, _bash_. In context, the usage of `[[` and `]]` is specific to BASH. (Tangentially, `[[` and `]]` also work with zsh and the Korn shell.) See BashFAQ/031. Portable scripts should be written with `[` and `]` which work in all POSIX shells.

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 11ed0a927738daa811484c5712c80443