help-bash
[Top][All Lists]
Advanced

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

Re: How to test if stdin is empty, if not empty print to stdout, otherwi


From: João Eiras
Subject: Re: How to test if stdin is empty, if not empty print to stdout, otherwise do something else.
Date: Wed, 25 Mar 2020 01:42:24 +0100

https://www.gnu.org/software/bash/manual/html_node/Bash-Builtins.html

if read -t 0 -u 0; then #  -u 0 is optional and just here as example
  echo stdin has input waiting
else
  echo stdin is empty
fi

You can play with the timeout parameter to retrieve incomplete lines of
input.


reply via email to

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