Terminal Output to a File ?? | Unix Linux Forums | UNIX for Advanced & Expert Users

  Go Back    


UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

Terminal Output to a File ??

UNIX for Advanced & Expert Users


Tags
tee

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 01-28-2008
varungupta varungupta is offline
Registered User
 
Join Date: Feb 2007
Last Activity: 15 July 2010, 5:53 AM EDT
Location: Pune, Dehradun (INDIA), Michigan(US)
Posts: 206
Thanks: 0
Thanked 1 Time in 1 Post
Error Terminal Output to a File ??

Hey,

How can I transfer the terminal output to a file ?

For example :

command "fuser" returns the "process-id" and prints the output on the terminal, but I want that output to a file as well. How can I do that ?

/clocal/mqbrkrs/user/mqsiadm/sanjay/AccessMonitor $ fuser -uf /clocal/mqbrkrs/user/mqsiadm/sanjay/AccessMonitor

OUTPUT ON TERMINAL :

/clocal/mqbrkrs/user/mqsiadm/sanjay/AccessMonitor: 1327500c(mqsiadm)

And I want this output to a file.

In general, the commands that gives output to the terminal or returns somthing, how can we get those to the file ?
I know about the 1> and 2> redirections.
What I am talking about, is redirection the output from Terminal to a File.

Can anyone help me !!

Thanks in advance !
Varun.
Sponsored Links
    #2  
Old 01-28-2008
KittyWu KittyWu is offline
Registered User
 
Join Date: Jan 2008
Last Activity: 12 August 2008, 9:30 AM EDT
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
The standard way of redirecting the output of a command into a file is to use the 'tee' command:

# Starts 'my_command' command and duplicates
# the outputs from the standard and error devices
# into the 'my_log.txt' log file
my_command 2>&1 | tee my_log.txt

Hope it helps,
C.
Sponsored Links
    #3  
Old 01-28-2008
varungupta varungupta is offline
Registered User
 
Join Date: Feb 2007
Last Activity: 15 July 2010, 5:53 AM EDT
Location: Pune, Dehradun (INDIA), Michigan(US)
Posts: 206
Thanks: 0
Thanked 1 Time in 1 Post
Computer

Quote:
Originally Posted by KittyWu View Post
The standard way of redirecting the output of a command into a file is to use the 'tee' command:

# Starts 'my_command' command and duplicates
# the outputs from the standard and error devices
# into the 'my_log.txt' log file
my_command 2>&1 | tee my_log.txt

Hope it helps,
C.
Hey,

Thanks man...I got it.

====================================================
Examples
1 To view and save the output from a command at the same time:
Code:
lint program.c | tee program.lint

This displays the standard output of the command lint program.c at the workstation, and at the same time saves a copy of it in the file program.lint. If a file
named program.lint already exists, it is deleted and replaced.
2 To view and save the output from a command to an existing file: lint program.c | tee -a program.lint

This displays the standard output of the lint program.c command at the workstation and at the same time appends a copy of it to the end of the program.lint file.
If the program.lint file does not exist, it is created.


====================================================

Thanks,
Varun.

Last edited by Yogesh Sawant; 05-26-2010 at 02:06 AM.. Reason: added code tags
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Output terminal sessions to screen and log file tdelliott UNIX Desktop for Dummies Questions & Answers 4 12-30-2008 09:14 AM
how to redirect my output in a new terminal Sayantan Solaris 0 06-29-2007 06:01 AM
terminal output - save to file? frustrated1 Solaris 2 11-15-2005 08:19 AM
output to terminal andreis Programming 6 10-16-2003 04:59 AM
Output to terminal and file at the same time Charlie UNIX for Dummies Questions & Answers 1 11-15-2001 08:19 AM



All times are GMT -4. The time now is 07:27 PM.