Timeline for Combine the output of two commands in bash
Current License: CC BY-SA 4.0
15 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| S Aug 14, 2024 at 6:08 | history | edited | G-Man Says 'Reinstate Monica' | CC BY-SA 4.0 | De-emphasized the `| cat` form; corrected and clarified wording. |
| S Aug 14, 2024 at 6:08 | history | suggested | Wyatt Carpenter | CC BY-SA 4.0 | "splits of" → "splits off". Plus nonsense because "Edits must be at least 6 characters;" |
| Aug 14, 2024 at 2:46 | review | Suggested edits | |||
| S Aug 14, 2024 at 6:08 | |||||
| May 7, 2020 at 6:53 | comment | added | Tim Malich | Why should I use | cat here? Seems to me as it works without cat just as fine. Or is this just to show some differences between () and {}? | |
| Apr 28, 2020 at 2:29 | comment | added | Zoey Hewll | This is an old answer so I realise I might not get a response, but when you say "more generally", do you mean in cases where the commands are not infinite? if so, it may be worth noting explicitly, as neither of these solutions will actually solve the problem as stated, where each command produces indefinite output. | |
| Jun 19, 2018 at 10:36 | comment | added | DarkMukke | i prefer the round brackets () as with the curly brackets {} it runs as a background progress and then you have to deal with the output from that. Also pipe to cat ` | cat` is a nicer alternative then ` > /dev/stdout` | |
| Apr 5, 2018 at 11:08 | comment | added | DUzun | Sometimes you want to run command2 only if command1 succeded: ( command1 && command2 && command3 ) | cat | |
| Nov 15, 2017 at 7:36 | comment | added | Ole Tange | Be warned: This doesn't preserve whole lines! You'll get unreliable outputs as lines get split up part way and mixed up among each other. You can try this with ( yes {1..20} & yes {1..20}; ) | grep -v '^1 2 3' which ideally won't print anything if lines aren't broken. (H/t to @antak). | |
| May 6, 2016 at 2:45 | comment | added | Wildcard | } isn't a command at all. It's a reserved word. Same goes for {. I usually write such lists like so: { command1;command2;} > outfile.txt. You can add spaces after the semicolons but it's not necessary. The space after { is necessary, though. | |
| Jan 1, 2015 at 12:49 | comment | added | muru | Redirection from ( ) works fine too. | |
| S Jan 1, 2015 at 12:48 | history | suggested | TPS | CC BY-SA 3.0 | added 6 chars |
| Jan 1, 2015 at 12:26 | review | Suggested edits | |||
| S Jan 1, 2015 at 12:48 | |||||
| Jan 1, 2015 at 12:24 | review | Late answers | |||
| Jan 1, 2015 at 12:36 | |||||
| Jan 1, 2015 at 12:09 | review | First posts | |||
| Jan 1, 2015 at 12:27 | |||||
| Jan 1, 2015 at 12:04 | history | answered | j9s | CC BY-SA 3.0 |