Given a file "foo.txt"
, created from:
$ seq 1 10 > "foo.txt"
I'm trying to read both the first and last line of the file, and I started by redirecting the file to a subshell, so that the list of commands will consume the file in sequence -- each command consumes the input from the point the last command has left it, I suppose:
$ (head -1; tail -1) < "foo.txt"
1
10
However, if I try the same with a temporary file descriptor, the output is not the same:
$ (head -1; tail -1) < <(seq 1 10)
1
Questions:
I'm not sure of what to name
<(seq 1 10)
, but what is the difference between this temporary file descriptor and a regular one ("foo.txt"
), that causes the subshell execution to behave differently?How can I achieve the same behavior of redirecting a
"foo.txt"
to the subshell, but without a temporary file -- without actually creating a file.