As true as this can be, it's counterintuitive.
post
I never use more than one redirection to keep it simple. Stuff gets even weirder when you also use < in the same lines
In bash if you want to redirect both stderr and stdout to file you can use &>filename.
IMO |& tee dirlist is easier to manage
This is a Bash thing?
https://www.man7.org/linux/man-pages/man1/bash.1.html
Pipelines A pipeline is a sequence of one or more commands separated by one of the control operators | or |&. The format for a pipeline is:
[time [-p]] [ ! ] command1 [ [|⎪|&] command2 ... ]
(...) If |& is used, command1's standard error, in addition to its standard output, is connected to command2's standard input through the pipe; it is shorthand for 2>&1 |. This implicit redirection of the standard error to the standard output is performed after any redirections specified by command1.
So it is a bash thing.
Just to be clear, because some seem to conflate Bash with Shell. If not specified, assume POSIX shell, that's how /bin/sh is handled as well. And that has no |&.
True
But nowadays /bin/sh is often just a link to bash
Your way would spawn a whole extra process, but if you're running Bash commands I suppose that doesn't often matter.
What distro uses /Users instead of /home? Doesn't that break the standard?
all 19 comments