Pass a pipe to a command that expects a filename

If I understand what you want to do properly, you can do it with bash's command substitution feature:

foo <(somecommand | pv)

This does something similar to what the mkfifo-based answers suggest, except that bash handles the details for you (and it winds up passing something like /dev/fd/63 to the command, rather than a regular named pipe). You might also be able to do it even more directly like this:

somecommand | pv | foo /dev/stdin

ARRAY=(`pv whatever`); for FILE in $ARRAY; do foo $FILE; done

This Unix SE question has a an answer that shows how to create a temporary named pipe:

Shell Script mktemp, what's the best method to create temporary named pipe?

Based on the answers there, you could do something like the following:

tmppipe=$(mktemp -u)
mkfifo -m 600 "$tmppipe"
pv examplefile > $tmppipe

You could then watch the pipe with:

foo $tmppipe

Then delete it when you're done with it.


Try using mkfifo.

mkfifo file_read_by_foo; pv ... > file_read_by_foo 

In another shell, run foo file_read_by_foo