When you need to write a log and put the same data to the tty, then tee is useful.
Plus
does not write anything to the tty. All stdout output goes into the file.
A best use of tee is:
To capture both errors and normal output. This way the person running the script sees what happened. Then support has a log file to refer to as well.
Greetings to everybody. I would like to know if I can use the pipe and command tee to read from edited file and to write to him e.g. "sed '{s_A_B_}' file | tee file". :confused: I know it doesn't work with > but I don't know anything about it with tee. Thank you for your help. :) (1 Reply)
hello
how to append the hostname to each line of a file that is tee'd
for example:
tail -f file1 | tee file2
Iwant file2 to have the same new lines of file1 but with the hostname at the end or the beginning of each line.
btw, is there more proper method than: tail -f file1 | tee... (1 Reply)
Hi,
I have a script where i want to log in details to the standard output as well as log file so that its easy for tracing purposes.
I have used the "tee"command.
The problem with this is my scripts lines are getting longer as for each line i have
#!/bin/ksh
echo "hello world" |... (4 Replies)
Hello
If anybody knows something about the following please help me.
I am using HP unix.
In a script called test.txt i have the following command
echo ok | tee test1.txt
It works fine.It prints ok on the screen and creates the file test1.txt and puts in the file the "ok".
In the same... (2 Replies)
I have been using the command tee to store the output to a file and also write on the terminal. However I would need to put the program in the background although I would still need to see the file being updated like it was doing when using tee.
Any suggestions on how to look at the log file... (3 Replies)
script1:
#!/bin/ksh
more test.txt
script2: calling the script1
#!/bin/ksh
/tmp/script1.sh 2>&1 | tee tee.log
where test.txt contains ~1200 lines.
When I execute the script2 the more command does not print pagewise it goes to the end of the line, when I remove the tee command it... (4 Replies)
Greetings!
My apologies if this has been answered elsewhere before. What I have is a function (as below) set up to append to either an error log or info log based upon input.
myLOGGER ()
{
if ]; then
logfile=$elog
lastERROR="$1" #used elsewhere in my script
else... (2 Replies)
In the current directory , I have seven files .
But when I use the following command , it lists eight files ( 7 files + file_list.xtx)
ls -1 | tee file_list.xtx | while read line; do echo $line ; done
Does the tee command create the file_list.xtx file first and then executes the ls -1... (1 Reply)
I'm on Ubuntu 14.04 and I manually updated my coreutils so that "tee" is now on version 8.27
I was running a script using bash where there is some write to pipe error at some point causing the tee command to exit abruptly while the script continues to run. The newer version of tee seems to prevent... (2 Replies)
Discussion started by: stompadon
2 Replies
LEARN ABOUT OSF1
tee
tee(1) General Commands Manual tee(1)NAME
tee - Displays the output of a program and copies it into a file
SYNOPSIS
tee [-ai] file...
STANDARDS
Interfaces documented on this reference page conform to industry standards as follows:
tee: XCU5.0
Refer to the standards(5) reference page for more information about industry standards and associated tags.
OPTIONS
Adds the output to the end of file instead of writing over it. Ignores the SIGINT signal.
OPERANDS
Standard input is stored into, or appended to, the file specified.
[Tru64 UNIX] The tee command can accept up to 20 file arguments.
DESCRIPTION
The tee command reads standard input and writes to both standard output, and each specified file.
The tee command is useful when you wish to view program output as it is displayed, and also want to save it in a file. The tee command does
not buffer output, so you may wish to pipe the output of tee to more if more than one full screen of data is anticipated.
NOTES
If a write to any file fails, the exit status of tee will be non-zero. Writes to all other specified files may be successful, and opera-
tion will continue until standard input is exhausted.
EXIT STATUS
The following exit values are returned: Successful completion. An error occurred.
EXAMPLES
To view and save the output from a command at the same time, enter: lint program.c | tee program.lint
This displays the standard output of the command lint program.c at the terminal, and at the same time saves a copy of it in the file
program.lint. If program.lint already exists, it is deleted and replaced. To display and append to a file, enter: lint program.c |
tee -a program.lint
This displays the standard output of lint program.c at the terminal and at the same time appends a copy of it to the end of pro-
gram.lint. If the file program.lint does not exist, it is created.
ENVIRONMENT VARIABLES
The following environment variables affect the execution of tee: Provides a default value for the internationalization variables that are
unset or null. If LANG is unset or null, the corresponding value from the default locale is used. If any of the internationalization vari-
ables contain an invalid setting, the utility behaves as if none of the variables had been defined. If set to a non-empty string value,
overrides the values of all the other internationalization variables. Determines the locale for the interpretation of sequences of bytes
of text data as characters (for example, single-byte as opposed to multibyte characters in arguments). Determines the locale for the for-
mat and contents of diagnostic messages written to standard error. Determines the location of message catalogues for the processing of
LC_MESSAGES.
SEE ALSO
Commands: cat(1), echo(1), script(1)
Standards: standards(5)tee(1)