1

When one sends data (say stdout) to a temporary file, it is likely that something would be done with that data (the temporary file will be used as stdin for some process), then the temporary file will be deleted.

A pipe is a variant of special files, that can chain together commands; passing output from one program, as the input of another.

Generally, a regular pipe would be destroyed right after the process, but a named pipe (commonly named, and not necessarily 100% accurate, "FIFO"), will keep alive after the process ended, until a certain point.

My question

A temporary file is likely to be deleted after usage and a named pipe isn't, but what is the difference between a temporary file and a pipe in general, or at least, an anonymous pipe?

Update

I was wrong to think that a "temporary file" a special file, it isn't; It is a regular file that just being used differently; I would say that a pipe differs in the sense that it is defined as a special file, and has a single narrow purpose (chaining), while a temporary file might have other usages besides chaining, but, there might be a more "total" way to describe the difference.

7
  • I swear I fail to see how this a duplicate --- there is no emphasis there, as I recon, to how the two pipes differ from a "temporary file". I believe a few people looked about this in Google. Apr 11, 2018 at 10:08
  • Point 2 of the suggested duplicate addresses the differences between pipes and temporary files. It’s just a suggestion though. Apr 11, 2018 at 10:14
  • Perhaps you could clarify what difference you see between a temporary file and a “regular” file... Apr 11, 2018 at 10:15
  • The only total difference I recon is that in general, a "temporary file" has a much shorter life cycle than a "regular file". Apr 11, 2018 at 12:00
  • Both are temporary and I want to understand how are they practically different. If FIFOs don't hold data on disk, where do they hold it temporarily when it is being passed through them? On RAM? An answer should define this. Apr 11, 2018 at 12:19

1 Answer 1

1

A named pipe may be temporary in the same sense that a regular file (or a network connection or anything else that provides a "handle" on data) can be temporary, i.e. it may be set up by a script to facilitate some sort of processing, and then deleted before the script exits. It would then be a "temporary (named) pipe".

A named pipe is a file, and so one could argue that the named pipe (which is indeed temporary) is a temporary file.

However, when people refer to a "file" then almost always refer to a "regular file" (i.e. a document of some description), and a named pipe is not a regular file.

A pipe in the shell, set up with | to provide a stream of data from one utility to another, is temporary in the sense that the shell will deallocate any resources related to it when it has been used and is no longer needed.

In the end, pipes (both named and not named) and regular files have different applications, and it should be clear when a regular file is used to store temporary data, and when a named pipe is used to pass data to another process.

Not the answer you're looking for? Browse other questions tagged .