Use I/O redirection to send output to a file rather than standard out. If you want all the output from your script to go to a file you would type scriptname > outfile at the command line. The > sign redirects the output to the file outfile. To append output to a file use >>.
You can also use this technique inside your script to direct output to multiple files. For example, if I wanted a logfile with execution status and an output file my script might look something like.
# Writing to files example
ps -aux > out.txt
printf "Job was a " > log.txt
if [ $rs = 0 ]
printf "%s\n" $SUCCESS >> log.txt
printf "%s\n" $FAILURE >> log.txt