2 ms·
This article was pretty comprehensive, including things like the ordering of `foo 2>&1 | bar`. I would like to offer a small difference of opinion on formattin
by neilv 5y ago
This article was pretty comprehensive, including things like the ordering of `foo 2>&1 | bar`.
I would like to offer a small difference of opinion on formatting: I encourage a space after `>` and `<`, before the filename argument. I guess it's subjective, and maybe varies by person, font, syntax coloring, etc., but... I think that both helps the redirection stand out, distinguishes it descriptor duplicating syntax, and avoids reduces punctuation clumped next to each other.
To use one of the author's examples:
cmd arg1 arg2 <myFile 3<&1 2>/dev/null >&2
cmd arg1 arg2 < myFile 3<&1 2> /dev/null >&2
cmd arg1 arg2 \
< myFile \
3<&1 \
2> /dev/null \
>&2
Keep in mind that, very often, the filenames will involve variable expressions (though I couldn't say objectively whether that's an argument for or against the space):
foo hello --today dog < "$InputFile" > "${OutputBase}.js"