0

How to combine these two commands?

./script.sh > logfile.log 

and

./script.sh 2> logfile.log

Thank you!

user3027198
  • 183
  • 3
  • 11

1 Answers1

3

In bash, to redirect both standard output and standard error to the same file, you can write

./script.sh &> logfile.log

If you want to be compatible with other shells,

./script.sh > logfile.log 2>&1
user000001
  • 32,226
  • 12
  • 81
  • 108