Pipes and FIFO

Pipes is one method to exchange data between two processes. In the following bash command a pipe is used:

ls | grep x

The | character stands for a pipe, the ls command prints out all the files in the current directory, however the output is put in a pipe and passed as input to the grep command. The grep command filters all filenames that do not contain a x. Such pipes are called unnamed pipes.

There are also named pipes that are called FIFO's (First In First Out). Named pipes look as regular files and are created as follows:

mkfifo pipe

The command ls -l shows p as first character to indicate that this is not a file but a pipe. Having created the pipe, test by opening two console windows . In the first console type ls -l > pipe and then in the second console cat < pipe.

Linurs Hosttech startpage