Either it is late in the day for me or I am missing something naive here.
here is a contrived example
#!/bin/bash
command="ls -al > check.txt"
$command
When I run this script on a shell it gives me error I guess due to the ">" operator. Anyway I can redirect the output from inside a shell script. I thought this was very straight forward:
ls -la > temp.txt
ls: cannot access >: No such file or directory
ls: cannot access temp.txt: No such file or directory