Piping into Shell scripts

Peter da Silva peter at ficc.uu.net
Thu Mar 8 02:56:52 AEST 1990


> > >Is there any way of getting a Shell script (C or Bourne) to recognise
> > >whether it is receiving input from a pipe?

... bunch of non-optimal answers deleted ...

if [ -t 0 ]
then
  echo "Standard Input is a terminal"
else
  echo "Standard input is not a terminal"
fi

Often, test ("[...]") is a builtin, saving you a fork/exec.
-- 
 _--_|\  `-_-' Peter da Silva. +1 713 274 5180. <peter at ficc.uu.net>.
/      \  'U`
\_.--._/
      v



More information about the Comp.unix.questions mailing list