Discussion:
[Help-bash] Is there a way to peek at the stdin buffer in bash?
Peng Yu
2016-11-09 14:49:45 UTC
Permalink
Hi, C has ungetc(). Is there a way to to peek stdin buffer in bash?
(This can be useful if I want to do something depending on the first
initial lines, otherwise I will need to write stdin to file or use
tee, either of which are as efficient as peeking the stdin buffer)
Thanks.
--
Regards,
Peng
Eduardo Bustamante
2016-11-09 15:02:27 UTC
Permalink
No, there's no such feature.

The only thing that comes to mind is that read with a timeout of 0
allows you to know if there's data, but there's no way to read that
data and then put it back.

Loading...