2009-07-29 9 views

risposta

16

È possibile verificare se un filedescriptor è un tty (collegato a un terminale) con il test di comando -t < filedescriptor n. >. Se lo è, puoi chiedere all'utente. In caso contrario, l'output è probabilmente convogliato o rediticato da qualche parte.

if test -t 1 ; then 
    echo stdout is a tty 
fi 
+0

Grazie! Esattamente quello che stavo cercando. – alberge