how can one turn off the error messages of a bash script?
I want to turn it off, and handle the expected ones by myself
For instance, when it does not find some files, to show my specific error message.
Thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You don’t want to turn them off – you want to capture them and parse them so you can show your own message. (Though if the script is well-written, you don’t actually have to capture them, just check the exit code.) You’ll need to redirect stderr
If you can do it just with the exit code, you can redirect to
/dev/nullinstead.For more about redirection, try the short version or long version here.