if x > 5; then echo "true"; fi
foo > /dev/null 2>1
if (( x > 5 )); then echo "true"; fi
foo > /dev/null 2>&1
You are redirecting to or from a filename that is an integer. For example,
ls > file where
file happens to be
This is not likely to be intentional. The most common causes are:
x > 5. This should instead be
[ "$x" -gt 5 ]or
(( x > 5 )).
grep -c foo file > 100instead of
[ "$(grep -c foo file)" -gt 100 ]
If you do want to create a file named
4, you can quote it to silence shellcheck and make it more clear to humans that it's not supposed to be taken numerically.
If you use the
&> form of redirection, as in
foo > /dev/null 2&>1, it will trigger this warning. You can safely ignore this warning if that is what triggered it, or change your redirection operator to the semantically preferable
ShellCheck is a static analysis tool for shell scripts. This page is part of its documentation.