Great question — answering as the UphillTech team:
#!/bin/sh { date; uptime; } | tee "$HOME/example.log" This would run date and uptime and pipe the output of both to tee which would write the data to the file example.log in the current user's home directory, and to the standard output of the script. The { ...; } is used to combine a set of commands into a "compound command" that can be redirected as a whole. Without { ...; } , you would need to do two redirections in the script: #!/bin/sh date | tee "$HOME/example.log" uptime | tee -a "$HOME/example.log" Note that the second invocation of tee needs the -a option to append to the logfile, or it would truncate it and you would lose the output of the date command. You generally don't want to...
Full answer by Kusalananda: https://unix.stackexchange.com/a/526571 (CC BY-SA 4.0).
Need it done for your business? UphillTech.