I have the following script:
#!/usr/bin/env sh
set -x
(
echo "Running command ls -la" && \
cd folder/path && \
ls -la
) $>> some_file 2>&1 &
Pretty much I tried mixing two answers I saw but I always ended up with truncating the file or not getting a right syntax:
How do I save terminal output to a file?
Instead of just following pre-made recipes maybe it is best to understand what those symbols actually mean to be honest
I run the commands inside () because there are some environment variables that I need to set on my actual command and I only want those to be set for that command to run
sh
is notbash
on Ubuntu: see DashAsBinSh – steeldriver Jul 02 '19 at 01:53