Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Confused about redirecting stderr Post 303030838 by Xubuntu56 on Sunday 17th of February 2019 09:21:45 AM
Old 02-17-2019
Wow! Thanks much. Smilie
I believe I found a use for >&2, uncommon though it may be: redirecting stdout to where stderr was previously redirected to.
Code:
{ ecko "Hello" || echo "World" } 2>error.txt >&2

resulting in
Code:
Command 'ecko' not found, did you mean:
  command 'echo' from deb coreutils
Try: sudo apt install <deb name>

World


Last edited by Xubuntu56; 02-17-2019 at 06:16 PM.. Reason: continued discussion
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

redirecting STDOUT & STDERR

In bash, I need to send the STDOUT and STDERR from a command to one file, and then just STDERR to another file. Doing one or the other using redirects is easy, but trying to do both at once is a bit tricky. Anyone have any ideas? (9 Replies)
Discussion started by: jshinaman
9 Replies

2. Shell Programming and Scripting

Redirecting stderr while live

If I forget to set up stderr redirection on execution of a script, is there a way to set that redirection post-exec? In other words, if I have a script running and no errors are being logged... and then I remember that I forgot the 2>&1 on the script... can I turn it on after the fact? ...and... (1 Reply)
Discussion started by: jjinno
1 Replies

3. Shell Programming and Scripting

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?? (10 Replies)
Discussion started by: vikashtulsiyan
10 Replies

4. Shell Programming and Scripting

Confused about redirecting output from awk.

I have a simple script written in awk whose purpose is to go through some php files and replace some strings. Naturally, I want the changes to be written out to the files. The script looks generally as follows: { gsub(/'replacethis'/, "with this"); # a bunch of these print $0 > FILENAME }... (3 Replies)
Discussion started by: face1
3 Replies

5. Shell Programming and Scripting

Redirecting stderr problem

% ls -ld /usr /foo ls: /foo: No such file or directory drwxr-xr-x 14 root wheel 512 May 18 02:49 /usr % ls -ld /usr /foo 1>/dev/null/ /dev/null/: Not a directory. % ls -ld /usr /foo 2>/dev/null/ /dev/null/: Not a directory. ^^Why why why doesn't this work for me. Furthermore, where is... (7 Replies)
Discussion started by: phpfreak
7 Replies

6. Shell Programming and Scripting

noob question about redirecting stderr

I dont know what I am doing wrong but I would like to redirect the stderr output to a file? the specific command is this time wget http://www.something.com/somefile.bin All I want to see is time's output which is stderr so I can see how long the file download took. I've tried redirecting... (2 Replies)
Discussion started by: trey85stang
2 Replies

7. Shell Programming and Scripting

Redirecting STDERR to a file from within a bash script

I am trying to redirect the output from stderr to a log file from within a bash script. the script is to long to add 2> $logfile to the end of each command. I have been trying to do it with the command exec 2> $logfile This mostly works. Unfortunately, when a read command requires that anything be... (5 Replies)
Discussion started by: vockleya
5 Replies

8. Shell Programming and Scripting

Is there a way to tee stderr from a command that's redirecting error to a file?

I'm not a complete novice at unix but I'm not all that advanced either. I'm hoping that someone with a little more knowledge than myself has the answer I'm looking for. I'm writing a wrapper script that will be passed user commands from the cron... Ex: ./mywrapper.sh "/usr/bin/ps -ef |... (1 Reply)
Discussion started by: sumgi
1 Replies

9. Shell Programming and Scripting

Preserve output order when redirecting stdout and stderr

Hi, I already searched through the forum and tried to find a answer for my problem but I didn't found a full working solution, thats way I start this new thread and hope, some can help out. I wonder that I'm not able to find a working solution for the following scenario: Working in bash I... (8 Replies)
Discussion started by: Boemm
8 Replies

10. Shell Programming and Scripting

Lost redirecting stderr & stdout to 3 files - one each plus combined

Hi folks I need/want to redirect output (stdout, stderr) from an exec call to separate files. One for stderr only and two(!) different (!) ones for the combined output of stderr and stdout. After some research and testing i got this so far : (( exec ${command} ${command_parameters} 3>&1... (6 Replies)
Discussion started by: MDominok
6 Replies
bup-newliner(1) 					      General Commands Manual						   bup-newliner(1)

NAME
bup-newliner - make sure progress messages don't overlap with output SYNOPSIS
<any command> 2>&1 | bup newliner DESCRIPTION
bup newliner is run automatically by bup. You shouldn't need it unless you're using it in some other program. Progress messages emitted by bup (and some other tools) are of the form "Message ### content", that is, a status message containing a vari- able-length number, followed by a carriage return character and no newline. If these messages are printed more than once, they overwrite each other, so what the user sees is a single line with a continually-updating number. This works fine until some other message is printed. For example, progress messages are usually printed to stderr, but other program mes- sages might be printed to stdout. If those messages are shorter than the progress message line, the screen will be left with weird looking artifacts as the two messages get mixed together. bup newliner prints extra space characters at the right time to make sure that doesn't happen. If you're running a program that has problems with these artifacts, you can usually fix them by piping its stdout and its stderr through bup newliner. BUP
Part of the bup(1) suite. AUTHORS
Avery Pennarun <apenwarr@gmail.com>. Bup unknown- bup-newliner(1)
All times are GMT -4. The time now is 07:06 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy