Problems with tee command.


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Problems with tee command.
# 1  
Old 02-03-2014
Problems with tee command.

Code:
for i in /tmp/*filex*; do echo $i |sed 's/\/tmp/infofiles\/infosize\/db\/files\///g';done 2>&1 |tee>output
|

The script works fine, but I cannot get the output to go to the screen and output at same time. I've tried tee -a tee and a number of commands but the only way I can get it working is to pipe it to a file and then on another line cat the file. Does anyone know how to do this with tee? I have tried even putting the commands in the loop.
# 2  
Old 02-03-2014
If you don't redirect the output of tee, it will go to standard output -- the terminal. You see no output because you have redirected standard output into a file.

Just tell tee the output file instead of redirecting it.

Code:
 ... | tee outputfile


Last edited by Corona688; 02-03-2014 at 04:50 PM..
This User Gave Thanks to Corona688 For This Post:
# 3  
Old 02-03-2014
Too Easy! Kept thinking you would need the > symbol in some place! Thanks!
# 4  
Old 02-03-2014
Quote:
Originally Posted by newbie2010
Code:
for i in /tmp/*filex*; do echo $i |sed 's/\/tmp/infofiles\/infosize\/db\/files\///g';done 2>&1 |tee>output
|

The script works fine
I respectfully doubt that claim. This:

Code:
sed 's/\/tmp/infofiles\/infosize\/db\/files\///g'

cannot work correctly, because the second "/" is not escaped. You probably mean

Code:
sed 's/\/tmp\/infofiles\/infosize\/db\/files\///g'

I hope this helps.

bakunin
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Using tee command with ablity to provide input for prompts

OS version: RHEL 7.4 Shell : bash I would like to capture command outputs using tee like # yum upgrade | tee yumupgradeLog But, if I use tee command, I cannot respond to prompts like Is this ok : during command execution as shown below. Is there a way I could use tee and still be able to... (4 Replies)
Discussion started by: kraljic
4 Replies

2. Shell Programming and Scripting

Help required with Stderr and tee command

Hello All, I have a requirement to redirect stdout and stderr to 'log' file and stderr alone to 'err' file. Can someone please help me with this? Thanks in advance (2 Replies)
Discussion started by: vikas_trl
2 Replies

3. Shell Programming and Scripting

Question about tee command

I have the following script as shown below where I cat a file and then also tee the output to a file as I have to email the execution of the process to users at the end of the script: cat incoming.dat | tee -a execution.log if then echo "Issue with incoming.dat file, file not... (5 Replies)
Discussion started by: calredd
5 Replies

4. 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

5. UNIX for Advanced & Expert Users

Equivalents of tee command to find exit status of command

Hi, Want to log the output of command & check the exit status to find whether it succeeded or failed. > ls abc ls: abc: No such file or directory > echo $? 1 > ls abc 2>&1 | tee log ls: abc: No such file or directory > echo $? 0 Tee commands changes my exit status to be always... (7 Replies)
Discussion started by: vibhor_agarwali
7 Replies

6. 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

7. 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

8. HP-UX

HP Unix Tee command.

work.txt M|324324|32424|3431 N|324324|32426|3432 N|324324|32424|3434 M|324324|32424|3435 AIX command: cat work.txt | tee >( grep '^M' > m.txt ) >( grep '^N' > n.txt ) which does not work on HP? Please adivse us. Error: cat work.txt | tee >( grep '^M' > m.txt ) >( grep '^N' > n.txt )... (7 Replies)
Discussion started by: rsampathy
7 Replies

9. UNIX and Linux Applications

Tee with pipe command.

cat work.txt M|324324|32424|3431 M|324324|32424|3431 N|324324|32426|3432 N|324324|32424|3434 M|324324|32424|3435 cat work.txt | tee $( grep '^M' > m.txt ) | $( grep '^N' > n.txt ) cehpny00:/home01/sr38632 $ cat m.txt M|324324|32424|3431 M|324324|32424|3431 M|324324|32424|3435 ... (2 Replies)
Discussion started by: rsampathy
2 Replies

10. Shell Programming and Scripting

Trouble with tee command to capture script outputs

function GetInput { print -n "Input" read input export INPUT=$input } export COMMAND="GetInput" $COMMAND echo "$INPUT" $COMMAND | tee -a Log.log echo "$INPUT" The first one without "tee" works fine. echo "$INPUT" displays the values I type in for input. The second... (5 Replies)
Discussion started by: muthubharadwaj
5 Replies
Login or Register to Ask a Question