Annika Backstrooms on Nostr: `cmd > file.txt 2>&1` vs `cmd 2>&1 > file.txt` always tripped me up: the first form ...
`cmd > file.txt 2>&1` vs `cmd 2>&1 > file.txt` always tripped me up: the first form is what I usually want (send both to file.txt) but always felt backwards to my brain.
Prompted by Julia, I read up on
https://www.gnu.org/software/bash/manual/html_node/Redirections.html and tried to understand why the first incantation sends both outputs to file.txt
Also TIL zsh "MULTIOS" which sends stdout to your pipe even if you've redirected to a file.
Published at
2024-08-30 21:51:47 UTCEvent JSON
{
"id": "76843c2917ecc9aac49846764da9853aabc5cdd23ae7196d7fdc796460ac25ef",
"pubkey": "475013bbafade70c184396129a4bcac8d6027ae2f6a9a977b52f894633d33969",
"created_at": 1725054707,
"kind": 1,
"tags": [
[
"imeta",
"url https://xoxo-media.sfo2.cdn.digitaloceanspaces.com/media_attachments/files/113/053/184/832/302/554/original/f185a9f454d699a1.png",
"m image/png"
],
[
"proxy",
"https://xoxo.zone/@annika/113053185303816476",
"web"
],
[
"proxy",
"https://xoxo.zone/users/annika/statuses/113053185303816476",
"activitypub"
],
[
"L",
"pink.momostr"
],
[
"l",
"pink.momostr.activitypub:https://xoxo.zone/users/annika/statuses/113053185303816476",
"pink.momostr"
],
[
"-"
]
],
"content": "`cmd \u003e file.txt 2\u003e\u00261` vs `cmd 2\u003e\u00261 \u003e file.txt` always tripped me up: the first form is what I usually want (send both to file.txt) but always felt backwards to my brain.\n\nPrompted by Julia, I read up on https://www.gnu.org/software/bash/manual/html_node/Redirections.html and tried to understand why the first incantation sends both outputs to file.txt\n\nAlso TIL zsh \"MULTIOS\" which sends stdout to your pipe even if you've redirected to a file.\nhttps://xoxo-media.sfo2.cdn.digitaloceanspaces.com/media_attachments/files/113/053/184/832/302/554/original/f185a9f454d699a1.png\n",
"sig": "ff29c401de7e3d1cee7b709d2f2774ab4290c93a8440d98963a4c359bd9813001dee120558d7d9145f13c12e9b7f2dc4501bbd7767baf19d39af72b23b33f6d8"
}