Generate script in bash and save it to location requiring sudo September 25, 2023 by Tarik This is how I would do it: sudo tee "$OUTFILE" > /dev/null <<'EOF' foo bar EOF