I am little confused and not sure, how to add the cat << EOF style to my script. Would really appreciate a little feedback and help.
Here is my script
!/bin/sh
#This is a disk mailer script for hdfs
DU_RESULTS_HOME=$(sudo -u hdfs hadoop fs -du -s /user/* | sort -r -k 1 -g | awk '{ suffix="KMGT"; for(i=0; $1>1024 && i < length(suffix); i++) $1/=1024; print int($1) substr(suffix, i, 1), $3; }'| head -n 22 |awk '{ print $1"\t\t\t" $2 }')
DF_RESULTS_HOME=$(sudo -u hdfs hadoop fs -df -h /user)
HOSTNAME=$(hostname -s)
MESSAGE_SUBJECT="Disk usage"
MESSAGE_SENDER="xyz"
MESSAGE_EMAIL="abc"
DU_RESULTS_HEADER_USER="Dir size User"
MESSAGE_BODY="Team:
High level Disk Usage Report for: /user
Please take a moment to clean out any old data, and write temp files to an appropriate filesystem, such as /tmp.
Thanks
if [[ --debug == "$1" ]]; then
echo debug on
printf '%s\n\n\n\n%s\n\n%s\n%s\n\n\n\n\n%s\n%s\n%s' "$MESSAGE_BODY" "$DF_RESULTS_HOME" "$DU_RESULTS_HEADER_USER" "$DU_RESULTS_HOME"
else
echo debug off
printf '%s\n\n\n\n%s\n\n%s\n%s\n\n\n\n\n%s\n%s\n%s' "$MESSAGE_BODY" "$DF_RESULTS_HOME" "$DU_RESULTS_HEADER_USER" "$DU_RESULTS_HOME" | /bin/mail -s "$MESSAGE_SUBJECT" -r "$MESSAGE_SENDER" "$MESSAGE_EMAIL"
fi
"
afterThanks
, to terminate the string. – steve Aug 03 '16 at 20:21<< EOF
thingy is called a "here document". See here, here and here. I'm not sure what you are asking about those two dozen lines of shell script, so I can't comment on that. – ilkkachu Aug 03 '16 at 20:50