The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 07-31-2008
satimis satimis is offline
Registered User
  
 

Join Date: Jun 2006
Posts: 45
Command display output on console and simultaneously save the command and its output

Hi folks,


Please advise which command/command line shall I run;

1) to display the command and its output on console
2) simultaneous to save the command and its output on a file


I tried tee command as follows;

$ ps aux | grep mysql | tee /path/to/output.txt

It displayed the command and its output on console but only saved the
output on output.txt without the command executed.


2)
$ ls -l | tee -a /path/to/outpu.txt

The output was added to the file also without the command.


3)
$ locate test.txt | tee -a /path/to/output.txt
locate: warning: database `/var/cache/locate/locatedb' is more than 8
days old

It won't add the warning on the file.


Please help. TIA


B.R.
satimis