{"action":"closed","issue":{"url":"https://api.github.com/repos/fish-shell/fish-shell/issues/2463","labels_url":"https://api.github.com/repos/fish-shell/fish-shell/issues/2463/labels{/name}","comments_url":"https://api.github.com/repos/fish-shell/fish-shell/issues/2463/comments","events_url":"https://api.github.com/repos/fish-shell/fish-shell/issues/2463/events","html_url":"https://github.com/fish-shell/fish-shell/issues/2463","id":110106471,"number":2463,"title":"Understanding multiple redirection","user":{"login":"kofalt","id":265071,"avatar_url":"https://avatars.githubusercontent.com/u/265071?v=3","gravatar_id":"","url":"https://api.github.com/users/kofalt","html_url":"https://github.com/kofalt","followers_url":"https://api.github.com/users/kofalt/followers","following_url":"https://api.github.com/users/kofalt/following{/other_user}","gists_url":"https://api.github.com/users/kofalt/gists{/gist_id}","starred_url":"https://api.github.com/users/kofalt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kofalt/subscriptions","organizations_url":"https://api.github.com/users/kofalt/orgs","repos_url":"https://api.github.com/users/kofalt/repos","events_url":"https://api.github.com/users/kofalt/events{/privacy}","received_events_url":"https://api.github.com/users/kofalt/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/fish-shell/fish-shell/labels/question","name":"question","color":"cc317c"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-10-06T21:36:46Z","updated_at":"2015-10-08T09:41:46Z","closed_at":"2015-10-08T09:41:46Z","body":"Suppose I wanted to manipulate multiple output streams of a command, without changing or combining what output is sent to which stream. This is ideal for modularity, so that a convenience filter (or whatever) doesn't preclude other, later uses.\r\n\r\nCreating an example `stuff` script that writes to stdout and stderr:\r\n\r\n```bash\r\n#!/bin/bash\r\n\r\necho \"One\"\r\necho \"Two\" 1>&2\r\n```\r\n\r\nI could fiddle with stdout via a pipe:\r\n\r\n```fish\r\n./stuff | sed 's/One/1/g'\r\n\r\n# Stdout: 1\r\n# Stderr: Two\r\n```\r\n\r\nTo simultaneously fiddle with stderr, I wrap everything in a block and use `2>|`:\r\n\r\n```fish\r\nbegin; ./stuff | sed 's/One/1/g'; end 2>| sed 's/Two/2/g' 1>&2\r\n\r\n# Stdout: 1\r\n# Stderr: 2\r\n```\r\n\r\nSuccess! Both streams were processed, without losing out/err information.\r\n\r\nI think the closest analogue in Bash is the following:\r\n\r\n```bash\r\n./stuff 1> >(sed 's/One/1/g') 2> >(sed 's/Two/2/g' 1>&2)\r\n\r\n# Stdout: 1\r\n# Stderr: 2\r\n```\r\n\r\nThis is bit more terse, but inferior to the fish example as the shell returns early.\r\n\r\n---\r\n\r\nI have two questions:\r\n\r\n1. Is my fish example correct & reasonable?\r\n2. Is there a better way to do multiple redirection in fish that I should be aware of?\r\n\r\nThanks! :sunglasses: "}}