Linked Questions
                        29 questions linked to/from How to trick a command into thinking its output is going to a terminal
                    
                
            
            
                27
            
            votes
        
        
            
                1
            
            answer
        
        
            
                10k
            
            views
        
        
            
            
            
        Make program in a pipe think it has tty [duplicate]
                    Test environment:
$ mkdir testdir
$ cd testdir
$ echo | tee "file 
name"
Now, ls will print file?name (under Ubuntu GNU bash, at least), while ls | cat will print file and name in separate lines.
...
                
            
       
        
            
                2
            
            votes
        
        
            
                1
            
            answer
        
        
            
                2k
            
            views
        
        
            
            
        Preserve systemctl colors while redirecting to a file [duplicate]
                    My Linux server is running SystemD (RHEL/CentOS/Debian/Ubuntu...).
I would like to redirect the output of systemctl list-dependencies to a file, but I want to preserve the ANSI colors (red or green ...
                
            
       
        
            
                4
            
            votes
        
        
            
                0
            
            answers
        
        
            
                745
            
            views
        
        
            
            
        filter journalctl output, preserve color [duplicate]
                    I am using journalctl to watch the system by journalctl -f -p 4, but I'd like to grep-out some information.
This works: journalctl -f -p 4|grep -v "maximal mount", but grep discards any color info, a ...
                
            
       
        
            
                1
            
            vote
        
        
            
                0
            
            answers
        
        
            
                419
            
            views
        
        
            
            
        How to redirect color output to a file? [duplicate]
                    echo -e "SUCCESS=$(tput setaf 1)$(tput setab 7)FALSE$(tput sgr 0) Share=$DIR1  \
                                LastCheckedDate=$(date +%Y_%m_%d_%H:%M:%S)" >> $ERROR_LOG 
In error log I am ...
                
            
       
        
            
                1
            
            vote
        
        
            
                1
            
            answer
        
        
            
                183
            
            views
        
        
            
            
        How can I convert terminal output? [duplicate]
                    I want to convert all output to the terminal that a certain command generates, using some filter program. How can I achieve this?
The immediate answer might be, “Use a pipeline”. However, too many ...
                
            
       
        
            
                1
            
            vote
        
        
            
                0
            
            answers
        
        
            
                79
            
            views
        
        
            
            
        Make any program "think" its output is a terminal (ie stop it from "knowing" its output is a pipe/file/substitution/etc) to keep ansi-color-codes etc [duplicate]
                    EDIT:
specifically what worked for me was using the python script in this answer
and I gave the tweaks I used to get it working for my autoloading functions in fishshell, and on ubuntu 20.04, in this ...
                
            
       
        
            
                0
            
            votes
        
        
            
                0
            
            answers
        
        
            
                30
            
            views
        
        
            
        How to bypass pipe detection? [duplicate]
                    A question at stackoverflow has answers that show the following way of detecting if standard output is a pipe:
if [ -t 1 ] ; then echo terminal; else echo "not a terminal"; fi
The -t flag ...
                
            
       
        
            
                36
            
            votes
        
        
            
                4
            
            answers
        
        
            
                20k
            
            views
        
        
            
            
            
        Why does sudo ignore aliases?
                    I am running Ubuntu 10.04 and I use upstart for daemon management.  My enterprise application is run as a daemon and must be run as root because of various privileges.  E.g.:
sudo start my-...
                
            
       
        
            
                22
            
            votes
        
        
            
                3
            
            answers
        
        
            
                5k
            
            views
        
        
            
            
        grep doesn't output until EOF if piped through cat
                    Given this minimal example
( echo "LINE 1" ; sleep 1 ; echo "LINE 2" ; )
it outputs LINE 1 and then, after one second, outputs LINE 2, as expected.
If we pipe this to grep LINE
( echo "LINE 1" ; ...
                
            
       
        
            
                21
            
            votes
        
        
            
                3
            
            answers
        
        
            
                3k
            
            views
        
        
            
            
        How does a program decide whether or not to have coloured output?
                    When I execute a command from a terminal that prints coloured output (such as ls or gcc), the coloured output is printed. From my understanding, the process is actually outputting ANSI escape codes, ...
                
            
       
        
            
                15
            
            votes
        
        
            
                1
            
            answer
        
        
            
                16k
            
            views
        
        
            
            
            
        Systemd Python service not sending all output to syslog
                    I have a custom service and have explicitly called for all stdout & stderr to be sent to syslog in the config file, however only some of the output appears in both syslog and the journal (they are ...
                
            
       
        
            
                5
            
            votes
        
        
            
                3
            
            answers
        
        
            
                3k
            
            views
        
        
            
            
        use line buffering when piping output to file
                    I have a perl program that prints to stdout, which I then pipe into a file, like this:
./skript.pl > file.txt 2>&1
This makes the output of that skript buffer. However, I would like to be ...
                
            
       
        
            
                5
            
            votes
        
        
            
                2
            
            answers
        
        
            
                3k
            
            views
        
        
            
            
            
        show escape sequences in terminal?
                    Is there a way to let the terminal show the raw escape sequence? (e.g. those used to control color)
I came across this UNIX.SE question, and want to filter "red" output ( Filter output of command by ...
                
            
       
        
            
                2
            
            votes
        
        
            
                2
            
            answers
        
        
            
                6k
            
            views
        
        
            
            
            
        How to stdin with tee or other kind of pipes or redirection of outputs? [closed]
                    Let's say I want to see the output what a command does, such as apt-get. However, if I would run a command redirecting the output such as
apt-get install some-application -y > apt_out.txt
or
apt-...
                
            
       
        
            
                3
            
            votes
        
        
            
                2
            
            answers
        
        
            
                3k
            
            views
        
        
            
            
        How to make any program work with the tee command?
                    I wrote a program (in Ruby) and it worked well. It prints out a few lines of text and then pause for a minute and then repeats the above.
It works well (in Mac OS X's terminal), but I noted that if I ...
                
            
       
         
         
         
         
        