Zend certified PHP/Magento developer

“: Permission denied /dev/null” error when trying to redirect output to /dev/null

When I do echo "test" >> /dev/null in bash it works great BUT when I do it in a bash script (test.sh) and try to run it (./test.sh) I get a : Permission denied /dev/null error.

https://unix.stackexchange.com/a/146639/54354 suggests that maybe /dev/null is a regular file but when I do vim /dev/null I get a "/dev/null" is not a file in the bottom left hand side of vim.

Here’s what I get when I do ls -latr /dev/null:

crw-rw-rw- 1 root root 1, 3 Dec 16 10:28 /dev/null

So it looks I have permission to write to it so idk what’s up.

Any ideas?