Laying a file through the tail and head through a tee

Starting here I tried to read the file and fix the head and tail of the file (read the file only once).

I tried the following: tee >(head) >(tail) > /dev/null < text.txt

This line works as expected, but I would like to get rid of / dev / null. So I tried: tee >(head) | tail < text.txt tee >(head) | tail < text.txt

But this line does not work as expected (well, as I expected), it prints the head, but does not return after that. Apparently, the tail is waiting for something. But I don’t know exactly what. I found this SO question , but I could not get it to work with these answers.

+2
bash shell tee
source share
1 answer

In tee >(head) | tail < text.txt tee >(head) | tail < text.txt text file goes directly to tail . You probably meant

 tee >(head) < text.txt | tail 

Which does not expect anything, but does not work, because the output of both the tee and the head goes in the tail.

Redirecting the header output to a new file descriptor and then returning it to work, but I'm not sure if it is "cleaner" than using / dev / null:

 ( tee >(head >&3) < text.txt | tail) 3>&1 
+5
source share

All Articles