Q:

std output and error from functions

Is there a way to get the standard output and estandard error from the functions inside a bash script? This is what "I thought" I was trying to accomplish with my script:
#!/bin/bash

LOGS="tmp/sync.log"

function1()
{
echo " "
echo "beginning function 1"
echo " "
for-loop-that-will-run-a-command
}

function2()
{
echo " "
echo "beginning function 2"
echo " "
for-loop-that-will-run-a-command
}

function1 2>&1 "$LOGS" &&
function2 2>&1 "$LOGS" ||

cat "$LOGS" | mailx -s "Here are the logs" myemail@domain.com

Bu I am not getting anything, what is the most efficient+elegant way to achieve this? 

A:

You do not redirect anything to $LOGS, but you only redirect stderr to stdout. 
So the correct redirection should be as follows to overwrite the $LOGS file.
function1 > "$LOGS"  2>&1 &&
function2 >> "$LOGS"  2>&1 ||

Or, as you are using bash, you could just use the commands as follows.
function1 &> "$LOGS" &&
function2 &>> "$LOGS" ||

