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: Peng Yu
Subject: Re: access the stdin of the parent process in a pipeline
Date: Wed, 25 Mar 2020 07:45:26 -0500

> 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

I never knew that I could add redirection after the function
declaration. This is neat.

-- 
Regards,
Peng



reply via email to

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