Using Named pipe in shell script

Hi,
I want to use a Named pipe to get input from a growing file for further processing. When I prototype this scenario using a while loop, the data is not written to the named pipe.

This the script I use to get data into the Named pipe:

#!/bin/ksh
mkfifo pipe
while (( n <= 10 ))
do
echo hi >> pipe
sleep 1
(( n ++ ))
echo $n
done

I have not used Named pipe before. I am not sure what I am missing. Please help.

Thanks.

The reason is that a pipe isn't some kind of storage, but only a (named) connection between both processes. By this definition it will block any writing attempt until there's a receiving process too. Open a second terminal and run tail -f pipe and you should see the difference.

Also, any process reading from a pipe (like cat) will block until something starts writing to the pipe.

Thanks a lot. Now I understood how the named pipe works.