Is there a standard bash tool that acts like echo but outputs to stderr rather than stdout?
I know I can do echo foo 1>&2
but it's kinda ugly and, I suspect, error prone (e.g. more likely to get edited wrong when things change).
Is there a standard bash tool that acts like echo but outputs to stderr rather than stdout?
I know I can do echo foo 1>&2
but it's kinda ugly and, I suspect, error prone (e.g. more likely to get edited wrong when things change).
No, that's the standard way to do it. It shouldn't cause errors.
Make a script
#!/bin/sh
echo $* 1>&2
that would be your tool.
Or make a function if you don't want to have a script in separate file.
You could define a function:
function echoerr() { echo "$@" 1>&2; }
echoerr hello world
This would be faster than a script and have no dependencies.