Hi,
I want to process stdin in the way that the first 10 lines are
processed by prog1, and the remaining lines are processed by prog2.
The output of prog1 is printed to stdout first, then the output of
prog2 is printed to stdout. No tempfiles should be created, but fifo
can be created. Is it possible?
When the input is not stdin, a script like the following can be easily
created. But when the input is a pipe, it is not clear to me what to
do without creating a tempfile.
/tmp$ seq 20 > file.txt
/tmp$ cat main.sh
#!/usr/bin/env bash
function prog1 {
cat
}
function prog2 {
cat
}
head -n 10 "$1" | prog1
tail -n +11 "$1" | prog2
/tmp$ ./main.sh file.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
--
Regards,
Peng