How to redirect all the bash script inside the script itself?

1

I need to play the output of it in a file instead of playing in the standard output that is the screen but without having to explicit with the command >> in the terminal, I want the script itself to do this.     

asked by anonymous 23.07.2018 / 00:42

1 answer

3

Do as follows:

{
   #seus comandos bash aqui
} > output.txt 2>&1

NOTE: If you do not specify the output path, the file will be generated in the directory where the bash script is located.

    
23.07.2018 / 03:26