Q:

How do you pipe commands from the Salesforce CLI to a text file?

I can use this to display a list of currently authed orgs: 
sfdx force:org:display

...and the same in JSON format:
sfdx force:org:display --json

However, trying any of these or similar combinations fails, and I don't see any mentions of piping in the CLI docs:
sfdx force:org:display --json | output.txt
sfdx force:org:display | output.txt
sfdx force:org:display  ./output.txt
sfdx force:org:display  .\output.txt
sfdx force:org:display  output.txt

Any starting point appreciated!

A:

To output text to a file, you don't want a "pipe", you want a "standard output redirect", which looks like this:
sfdx force:org:display --json > output.txt

Where > instructs the OS to redirect STDOUT to the named file.
Pipes are used when you want to send STDOUT of one program to STDIN of another, such as this trivial example:
sfdx force:org:display --json | wc

Where wc is a program that outputs the number of characters, words, and lines in a file.

