[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: nur stderr in eine pipe - wie?



On Fri, 25 Apr 2014 08:18:47 +0200
Matthias Böttcher <matthias.boettcher@gmail.com> wrote:

> Hallo an alle,

Hi,
> ich möchte in der bash die Fehlerausgabe eines Kommandos (stderr bzw.
> fd 2) in eine pipe (zu grep) schicken. Die Standardausgabe soll
> _nicht_ in die pipe umgelenkt werden.

also stdout soll normal in dein Terminal ausgeben werden und stderr
willst du filtern?
Ich denke hierfür musst du einen dritten Descriptor verwenden:

$ exec 3>&1
$ ls foo bar blub 2>&1 >&3 
ls: cannot access bar: No such file or directory
ls: cannot access blub: No such file or directory
foo
$ ls foo bar blub 2>&1 >&3 | grep bar
foo
ls: cannot access bar: No such file or directory
 
Liebe Grüße,
Micha


Reply to: