Here is a simple shell that works for that.
#!/bin/bash exec 1<&- exec 2 shell_result.txt exec 2>&1 ls -l ls fake_data echo "Done"
It will close standard output/error and open that file descriptors for the file shell_result.txt. As a result, all the following commands’ output will be redirected to the specified file.
Leave a Reply