will a named pipe always be size 0 on filesystem?

I did

cat < myFile >> myPipe

I was hoping that if I did ls -l, myPipe would now be holding the contents of myFile, and would be the same size. But it was 0.

Also strange was that when I did the command above, cat did not return control back to the shell. Why?

thanks

Your command doesn't return back control to the shell until some process reads the content of the named pipe.

After issuing that command, open another shell and type "cat myPipe": at this point the content of myPipe (that is, the content of myFile) is displayed and the first shell will return to the prompt.

About the zero size, yes, a named pipe doesn't use space on disk. Otherwise what would be the difference between a named pipe and a temporary file?

To be honest, on this point I am not totally sure, maybe googling around about this argument may clear our ideas. Or maybe some more experienced user could put light on this doubt :slight_smile:

thanks for your answer, it gives me all the information I needed

There are several different implementations of named pipes and OS's often switch to move to a faster implementation. With some implementations, a non-zero size is possible but it's been about 25 years since I saw an example of that (HP-UX 3.1). You should ignore the size field for a named pipe.

thanks for your answer