Answer the question
In order to leave comments, you need to log in
How to determine inside the program where the output goes to the terminal or to the file?
Hello.
If you write ls in the terminal, for example, it will display something like this:
Makefile ft_ls libft output2.txt
author inc output.txt src
Makefile
author
ft_ls
inc
libft
output.txt
output2.txt
src
Answer the question
In order to leave comments, you need to log in
The author noticed that the output is different, that he himself sent the output to the file, he is aware :)
You can find out if we are writing to the terminal like this:
istty is in io.h, and fileno is in stdio.h
And ls, it really looks if the output is in the terminal - then in one line, otherwise - in several: https://github.com/coreutils/coreutils/blob/master...
It doesn't define anything. It is you who determines where the output will go, cmd > file You wrote)))
In the usual case, the command will spit out everything to the standard output.
So you yourself let her know that you are redirecting the output with the symbol ">"
I / O redirection in Linux
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question