I am trying to understand named pipes in the context of this particular example.
I type <(ls -l)
in my terminal and get the output as, bash: /dev/fd/63: Permission denied
.
If I type cat <(ls -l)
, I could see the directory contents. If I replace the cat
with echo
, I think I get the terminal name (or is it?).
echo <(ls -l)
gives the output as /dev/fd/63
.
Also, this example output is unclear to me.
ls -l <(echo "Whatever")
lr-x------ 1 root root 64 Sep 17 13:18 /dev/fd/63 -> pipe:[48078752]
However, if I give,ls -l <()
it lists me the directory contents.
What is happening in case of the named pipe?
mkfifo
which is when I got this question about named pipes. So, if I have understood correctly,mkfifo
is something which does effectively<(ls -l)
in one process and unless you issuecat
in another process, it will remain blocked. Am I correct in my understanding? – Ramesh Sep 17 '14 at 19:09mkfifo
only creates the named pipe, without any content. So you need to write to it yourself (e.g.mkfifo mypipe; ls > mypipe
). And yes, the writes to the pipe will block until some process reads from the pipe. – crater2150 Sep 17 '14 at 19:15/dev/fd/63
is an anonymous pipe. – Gilles 'SO- stop being evil' Sep 17 '14 at 21:06file <(ls)
. The shell does create an anonymous pipe, but the file descriptor reflects as a named pipe in/dev/fd
. If it were an anonymous pipe, it would not have a name and could not be opened by a command to which/dev/fd/63
is passed. – r.v Feb 08 '16 at 19:35/dev/fd
can refer to any file descriptor, even anonymous pipes and sockets, network sockets, shared memory segments, etc. – Gilles 'SO- stop being evil' Feb 08 '16 at 20:00