Programming Tips - bash: check if output is a tty

Date: 2021nov4 Language: bash Q. bash: check if output is a tty A. Use the -t <file-descriptor> option of test
if [ -t 1 ]; then echo 'Output is a tty' fi
Do NOT replace [ with [[ since this option is only in test which is [ 1 is the file descriptor of stdout.