I'm writing a script to execute bash commands in the PHP CLI. I would like to suppress errors from bash and write my own error message if an error occurs.
So far I have this (assuming log.txt doesn't exist!):
tac log.txt 2>/dev/null
Which works as expected, tac kicks up an error but the error is suppressed, but when I use this:
tac < log.txt 2>/dev/null
bash: log.txt: No such file or directory
The tac error is suppressed but bash still gives me a dirty error.
Does anyone know how to suppress this?