LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 06-24-2008, 06:53 AM   #1
techsavvy
LQ Newbie
 
Registered: Jun 2008
Posts: 4

Rep: Reputation: 0
How can I save gcc output in a file ?


Hi,

I want to save the output from terminal into a file when I run gcc command.
I tried the usual method, gcc sample.c > filename.txt , but still the output gets printed at terminal and not in the file.

./a.out > filename.txt works but not gcc sample.c > filename.txt

Can anyone tell how can I redirect gcc command output(errors, warnings etc.)in a file ?
 
Old 06-24-2008, 06:59 AM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978
gcc output is sent to standard error, so
Code:
gcc sample.c 2> filename.txt
should do the trick.
 
Old 06-24-2008, 07:20 AM   #3
techsavvy
LQ Newbie
 
Registered: Jun 2008
Posts: 4

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by colucix View Post
gcc output is sent to standard error, so
Code:
gcc sample.c 2> filename.txt
should do the trick.

hey thanks,

I got my problem solved.
 
Old 06-24-2008, 07:38 AM   #4
tronayne
Senior Member
 
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,541

Rep: Reputation: 1060Reputation: 1060Reputation: 1060Reputation: 1060Reputation: 1060Reputation: 1060Reputation: 1060Reputation: 1060
You can also pipe the output into the tee utility; you'll see the output on the screen and it'll be simultaneously written to a file.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to save output of 'fuser' to a file p_raju AIX 5 05-31-2008 04:18 AM
how to save output of 'fuser' to a file p_raju Linux - General 2 05-28-2008 10:50 AM
Screen Listing Output Save in a File rolly frando Linux - Newbie 3 07-04-2005 01:23 AM
PHP: save output to a file mikeshn Programming 2 10-25-2003 06:57 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 02:30 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration