I want the output of this script to be a body of the email message but I don't want to redirect it to a file first and then to an email, basically no external login/output files - all action should be done within the script itself - is it possible to do it?
Example:
#!/bin/bash
email() {
echo "Results:"
}
for i in $(ls -1 test); do
if [ -f "test/$i" ]; then
echo "'$i' it's a file."
else
echo "'$i' it's a directory."
fi
done
email | mail -s "Test" [email protected]
Output:
$ ./tmp.sh
'd1' it's a directory.
'f1' it's a file.