Sponsored Content
Full Discussion: Using tee
Top Forums Shell Programming and Scripting Using tee Post 302461329 by kristinu on Sunday 10th of October 2010 10:46:16 AM
Old 10-10-2010
Using tee

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 whilst it's being updated?
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

tee problem

Hi you, This the code I have: function show_menu { echo " lalalalal" echo " 1. ...." echo " 2. ...." echo " 3. exit" read choice case $choice in 1) ... ;; 2) ...;; *) stop=1;; esac } (5 Replies)
Discussion started by: bensky
5 Replies

2. UNIX for Dummies Questions & Answers

How does tee work

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)
Discussion started by: Foxgard
1 Replies

3. UNIX for Dummies Questions & Answers

tee

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)
Discussion started by: melanie_pfefer
1 Replies

4. Shell Programming and Scripting

removing tee

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)
Discussion started by: pinnacle
4 Replies

5. Shell Programming and Scripting

tee

Someone recently advised me to use the tee command to write to standard out. Why would you pipe your commands to tee -a <filename> rather than just using >> <filename> ? For example: date|tee -a myfile seems to be the same as date >> myfile Is there a benefit to... (5 Replies)
Discussion started by: fracken_toaster
5 Replies

6. UNIX for Dummies Questions & Answers

tee command within variable

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)
Discussion started by: kostasch
2 Replies

7. Shell Programming and Scripting

tee + more command

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)
Discussion started by: prasad111
4 Replies

8. Shell Programming and Scripting

tee and functions

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)
Discussion started by: reid
2 Replies

9. Shell Programming and Scripting

Help with tee command

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)
Discussion started by: kumarjt
1 Replies

10. Shell Programming and Scripting

Mindboggling difference between using "tee" and "/usr/bin/tee" in bash

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
TEE(2)							     Linux Programmer's Manual							    TEE(2)

NAME
tee - duplicating pipe content SYNOPSIS
#define _GNU_SOURCE #include <fcntl.h> ssize_t tee(int fd_in, int fd_out, size_t len, unsigned int flags); DESCRIPTION
tee() duplicates up to len bytes of data from the pipe referred to by the file descriptor fd_in to the pipe referred to by the file descriptor fd_out. It does not consume the data that is duplicated from fd_in; therefore, that data can be copied by a subsequent splice(2). flags is a series of modifier flags, which share the name space with splice(2) and vmsplice(2): SPLICE_F_MOVE Currently has no effect for tee(); see splice(2). SPLICE_F_NONBLOCK Do not block on I/O; see splice(2) for further details. SPLICE_F_MORE Currently has no effect for tee(), but may be implemented in the future; see splice(2). SPLICE_F_GIFT Unused for tee(); see vmsplice(2). RETURN VALUE
Upon successful completion, tee() returns the number of bytes that were duplicated between the input and output. A return value of 0 means that there was no data to transfer, and it would not make sense to block, because there are no writers connected to the write end of the pipe referred to by fd_in. On error, tee() returns -1 and errno is set to indicate the error. ERRORS
EINVAL fd_in or fd_out does not refer to a pipe; or fd_in and fd_out refer to the same pipe. ENOMEM Out of memory. VERSIONS
The tee() system call first appeared in Linux 2.6.17. CONFORMING TO
This system call is Linux-specific. NOTES
Conceptually, tee() copies the data between the two pipes. In reality no real data copying takes place though: under the covers, tee() assigns data in the output by merely grabbing a reference to the input. EXAMPLE
The following example implements a basic tee(1) program using the tee() system call. #define _GNU_SOURCE #include <fcntl.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <errno.h> #include <limits.h> int main(int argc, char *argv[]) { int fd; int len, slen; if (argc != 2) { fprintf(stderr, "Usage: %s <file> ", argv[0]); exit(EXIT_FAILURE); } fd = open(argv[1], O_WRONLY | O_CREAT | O_TRUNC, 0644); if (fd == -1) { perror("open"); exit(EXIT_FAILURE); } do { /* * tee stdin to stdout. */ len = tee(STDIN_FILENO, STDOUT_FILENO, INT_MAX, SPLICE_F_NONBLOCK); if (len < 0) { if (errno == EAGAIN) continue; perror("tee"); exit(EXIT_FAILURE); } else if (len == 0) break; /* * Consume stdin by splicing it to a file. */ while (len > 0) { slen = splice(STDIN_FILENO, NULL, fd, NULL, len, SPLICE_F_MOVE); if (slen < 0) { perror("splice"); break; } len -= slen; } } while (1); close(fd); exit(EXIT_SUCCESS); } SEE ALSO
splice(2), vmsplice(2), feature_test_macros(7) COLOPHON
This page is part of release 3.27 of the Linux man-pages project. A description of the project, and information about reporting bugs, can be found at http://www.kernel.org/doc/man-pages/. Linux 2009-09-15 TEE(2)
All times are GMT -4. The time now is 09:42 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy