![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to use tee with stdout and stderr? | siegfried | Shell Programming and Scripting | 3 | 01-14-2009 10:07 PM |
| combined stdout & stderr | slavam | UNIX for Advanced & Expert Users | 11 | 10-12-2007 03:06 PM |
| redirecting STDOUT & STDERR | jshinaman | Shell Programming and Scripting | 9 | 06-22-2007 12:04 AM |
| stderr & stdout to a file and the right exit code | up69 | Shell Programming and Scripting | 2 | 08-17-2006 01:40 PM |
| Redirect stdout & stderr and append to a file | Santi | Shell Programming and Scripting | 2 | 01-02-2006 07:58 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Redirecting STDERR message to STDOUT & file at same time
Friends
I have to redirect STDERR messages both to screen and also capture the same in a file. 2 > &1 | tee file works but it also displays the non error messages to file, while i only need error messages. Can anyone help?? |
|
||||
|
Use this:
Script is "cmd" Code:
#!/bin/sh echo "This is Standard Out" echo "This is Standard Error" >&2 Code:
((./cmd 3>&1 1>&2 2>&3) | tee /dev/tty) > err.log Code:
((./cmd 3>&1 1>&2 2>&3) | tee /dev/tty) > err.log This is Standard Out This is Standard Error Code:
cat err.log This is Standard Error ![]() |
![]() |
| Bookmarks |
| Tags |
| redirect, stderr |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|