Monday 25 March 2019

bash - How to combine these two commands?: ./script.sh > logfile.log and ./script.sh 2> logfile.log




How to combine these two commands?



./script.sh > logfile.log 


and




./script.sh 2> logfile.log


Thank you!


Answer



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

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...