Sample Header Ad - 728x90

How to trick a command into thinking its output is going to a terminal

87 votes
8 answers
21877 views
Given a command that changes its behaviour when its output is going to a terminal (e.g. produce coloured output), how can that output be redirected in a pipeline while preserving the changed behaviour? There must be a utility for that, which I am not aware of. Some commands, like grep --color=always, have option flags to force the behaviour, but the question is how to work around programs that rely solely on testing their output file descriptor. If it matters, my shell is bash on Linux.
Asked by Amir (1891 rep)
Dec 16, 2015, 01:39 PM
Last activity: Mar 25, 2025, 03:01 PM