I'm working my way through William Shotts Jr.'s great The Linux Command Line on my Mac OSX 10.7.5 system. 90% of the linux that Shotts covers is close enough to Darwin that I can figure out or GTEM to figure out what's going on. I've made it to chapter 27 on "Writing Shell Scripts" and am getting hung up creating "here files" within a function.
I get an syntax error: unexpected end of file error when I include the following function:
report_uptime () {
cat <<- _EOF_
<H2>System Uptime</H2>
<PRE>$(uptime)</PRE>
_EOF_
return
}
The error goes away if I use the following function placeholder:
report_uptime () {
return
}
Also, elsewhere in the script, outside of a function I use the cat << _EOF_ format to create a "here file" with no trouble:
cat << _EOF_
<HTML>
<HEAD>
<TITLE>$TITLE</TITLE>
</HEAD>
<BODY>
<H1>$TITLE</H1>
<P>$TIME_STAMP</P>
$(report_uptime)
$(report_disk_space)
$(report_home_space)
</BODY>
</HTML>
_EOF_
If anyone has any idea what I'm doing wrong I would be grateful!
[-]is an option for Darwin's here files.cat << _EOF_notcat <<- _EOF_– BenU Nov 24 '12 at 20:32