![]() |
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 |
| Redirecting STDERR message to STDOUT & file at same time | vikashtulsiyan | Shell Programming and Scripting | 10 | 04-09-2008 03:34 PM |
| how can i redirect stderr to file in Make? | umen | Shell Programming and Scripting | 0 | 02-15-2007 04:04 AM |
| redirect stderr and/or stdout to /dev/null from command line | knc9233 | UNIX for Dummies Questions & Answers | 1 | 01-25-2007 12:24 PM |
| stderr & stdout to a file and the right exit code | up69 | Shell Programming and Scripting | 2 | 08-17-2006 02:40 PM |
| Redirect stdout and stderr | zcurtis | Shell Programming and Scripting | 8 | 09-02-2002 07:13 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Redirect stdout & stderr and append to a file
Hello
![]() I want to append to a file the stdout and stderr outputs from script, this works fine: Code:
$ ./script.pl >> /tmp/outputs.txt 2>> /tmp/outputs.txt Code:
$ ./script.pl &>> /tmp/outputs.txt -bash: syntax error near unexpected token `>' Code:
$ ./script.pl &> /tmp/outputs.txt Thanks! -- Santi Saez |
|
||||
|
Why you "want to use just one redirection" eludes me.
It is possible to redirect one output channel to another like "2>&1" which means "put the output of channel 2 (stderr) where right now channel 1 (stdout) goes" and let channel 1 point to a file: process >>file 2>&1 But to be honest i would prefer you first solution with separately mentioned files for stdout and stderr anytime on weekdays and twice on sundays - it makes a much easier to maintain code AND it is not position dependent: process >file 2>&1 will have stderr and stdout go to <file>, but: process 2>&1 >file will have stdout go to <file> and stderr to - screen! , because when the direction channel 2 should point to is evaluated channel 1 is still pointing to the terminal and not to the file. This is one of the most common errors in crontabs and responsible for an awful lot of unnecessary (and unwanted) mails to root (the cronjobs replacement for a terminal). bakunin |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|