Is it possible to send verbose o/p of gcc to text file instead of standard output?
I am trying to run the command :
$ gcc --save-temps --verbose ex1.c -o ex1__
and want to save the result in text file rather for easy reference later.
Am using cygwin 7.3.0, with GNU C version 7.3.0.
Re: Is it possible to send verbose o/p of gcc to text file instead of standard output
$ gcc --save-temps --verbose ex1.c -o ex1__ 2>&1 | tee a.txt
The above works, but would like to know if any other way exists too, or not. If not, then why not.
Re: Is it possible to send verbose o/p of gcc to text file instead of standard output
Wouldn't normal input redirection work? Say:
Code:
$ gcc --save-temps --verbose ex1.c -o ex1 2> gcc_errors.txt
Re: Is it possible to send verbose o/p of gcc to text file instead of standard output
Quote:
Originally Posted by
laserlight
Wouldn't normal input redirection work? Say:
Code:
$ gcc --save-temps --verbose ex1.c -o ex1 2> gcc_errors.txt
No, the text file is just created but empty. For a new file (not created yet) used >, but failed. Even using >> (so as to append contents) does not help.
Re: Is it possible to send verbose o/p of gcc to text file instead of standard output
When dealing with the console, there are 3 standard streams.
0 - stdin
1 - stdout
2 - srderr
To redirect stdout to a file use > {fn} (to overwrite) or >>{fn} (to append). To redirect stderr use 2> {fn} (or 2>> {fn}). To redirect stdin use < {fn}.
By default, both stdout and stderr show their output to the console.
PS, in your post #2, 2> &1 | tee a.txt
This causes stderr to go to stdout. stdout is piped (|) to the program tee as stdin. Tee gets its input from stdin (| effectively connects stdout to stdin) and writes its output to both stdout and to the specified file (a.txt).
Re: Is it possible to send verbose o/p of gcc to text file instead of standard output
Quote:
Originally Posted by
2kaud
When dealing with the console, there are 3 standard streams.
0 - stdin
1 - stdout
2 - srderr
To redirect stdout to a file use > {fn} (to overwrite) or >>{fn} (to append). To redirect stderr use 2> {fn} (or 2>> {fn}). To redirect stdin use < {fn}.
By default, both stdout and stderr show their output to the console.
I expected the same, but it leads to a new file (if not already there, with >) which is empty, or causes no change with >> to an existing file.
I am sorry, but request confirmation for {fn}. I expect it as abbreviation for {file name}.
Re: Is it possible to send verbose o/p of gcc to text file instead of standard output
Quote:
I am sorry, but request confirmation for {fn}. I expect it as abbreviation for {file name}.
Yes. Also my PS to my post #5.
Re: Is it possible to send verbose o/p of gcc to text file instead of standard output
Quote:
I expected the same, but it leads to a new file (if not already there, with >) which is empty, or causes no change with >> to an existing file.
Do you still get anything showing on the console?
PS you don't have a space between the 2 and the > do you? It needs to be 2> with no space. 2 > means something different!
Re: Is it possible to send verbose o/p of gcc to text file instead of standard output
Quote:
Originally Posted by
2kaud
Do you still get anything showing on the console?
PS you don't have a space between the 2 and the > do you? It needs to be 2> with no space. 2 > means something different!
$ gcc --save-temps --verbose ex1.c -o ex1__ 2>&1 | tee a.txt
There is no space between '2' & '>'.
Would request the meaning (action generated by) of '2 > '.
Re: Is it possible to send verbose o/p of gcc to text file instead of standard output
2 > means use 2 as a command-line parameter and redirect stdout (instead of 2> which redirects stderr!).
Re: Is it possible to send verbose o/p of gcc to text file instead of standard output
Quote:
Originally Posted by
2kaud
2 > means use 2 as a command-line parameter and redirect stdout (instead of 2> which redirects stderr!).
Thanks a lot. Please tell where to look for such information. I request that if some googling term be stated for the same, then even better.
Re: Is it possible to send verbose o/p of gcc to text file instead of standard output
See https://support.microsoft.com/en-us/...-stderr-stdout
If you search https://msdn.microsoft.com/en-us/ with relevant search terms, you usually find required info.
There's also years of experience! :cool: