-t FD (conditional operator)

true if FD is a file descriptor, which is opened on a terminal.

Examples

Different ways to test if a file descriptor is opened on a terminal:
1
2
3
4
test -t 1 && echo "stdout opened on terminal"
[ -t 1 ] && echo "stdout opened on terminal"
# Bash
[[ -t 1 ]] && echo "stdout opened on terminal"
BashSupport Pro is a Bash IDE with support for -ttry it now!
© 2020–2024 Joachim Ansorg
Imprint
Privacy Policy
Legal