This article will show you how to redirect command outputs to file in Bash.
command &> output.txt
If you want data to be added to an existing file use
#!/bin/bash echo "text from the script"
Redirect the command output to the
output.txt file by:
$ ./my_script.sh &> output.txt
text from the script