Piping between shells
Create your own bash pipes to send program output between shells, processes and users.
You may already be familiar with the | command commonly used to send the output of one command into another, e.g.
cat /var/log/messages | less. Here we create user-defined pipes to carry output between shells or users.
You will need to set appropriate permissions on the pipe file to share data between users. Try
chmod 644 fifo_pipe.
First create the pipe through which you’ll send the data using the
mkfifo command. This refers to the type of buffer you are creating: ‘first in first out’ i.e. a pipe.
Open up a new shell - either open a new terminal window or start a new session. Keep your previous one running so you can send the data from there. In the new window enter:
tail -f ~/fifo_pipe
tail (which outputs the end of the buffer) with the
-f option to ‘follow’ output - that is continue outputting what it finds in the fifo pipe.
Return to the original shell session and now enter:
ls >> ~/fifo_pipe
Running this will perform a directory listing of the current directory, outputting the result into the
fifo_pipe we previously created. Now switch back to your second session and see the output of
You can send any data output from one process through a pipe in this way.
- Use screen to manage persistent sessions
- Reload .bash_profile without logging in again
- Find all files containing a given string
- Get file type information from the command line
- Get a list of all processes not run by you
Get my latest Python projects, tips & tutorials direct to your Inbox.