help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: access the stdin of the parent process in a pipeline


From: Koichi Murase
Subject: Re: access the stdin of the parent process in a pipeline
Date: Wed, 25 Mar 2020 13:33:19 +0900

2020/3/21 12:39 Peng Yu
> $ function f { seq 3 | awk -e 'BEGIN { while(getline < "/dev/stdin")
> print } { print }' /dev/stdin; }
>
> What is the correct way to access the parent process stdin in a
> pipeline? Thanks.
>

Redirect?

function g1 {
  seq 3 | awk -e 'BEGIN { while(getline < "/dev/stdin") print } {
print }' /dev/fd/4
} 4<&0

$ seq 4 | g1
1
2
3
1
2
3
4

Note that /dev/fd/N is system dependent. Even if the system doesn't
support these devices, GNU awk specially treats the filename of the
form /dev/fd/N, but I'm not sure for the other awk implementations.

Best regards,
Koichi



reply via email to

[Prev in Thread] Current Thread [Next in Thread]