0

I'm redirecting output of a command to a log file in a shell script as follows :

script > file.log

However, towards the end of the script, some of the final content which includes key information like "PASS" or "FAIL" gets printed on the console rather than re-directed to file.log

I would like this information to be re-directed as well. Any tips?

1 Answer 1

3

Most likely the output of "PASS" "FAIL" is output to stderr instead of stdout, so you want to redirect both stdout and stderr to your file, e.g.

script > file.log 2>&1

(or you can shortcut the command with script &> file.log)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.