Shell:意外的文件结束

时间:2016-01-12 16:03:46

标签: linux shell ubuntu

我正试图找到我可能有不匹配标签或引号的地方,但这是在逃避我。我收到的错误是第48行的意外EOF,它只告诉我我已经知道的内容。这是我的简单脚本:

#!/bin/bash

# Program to output a system information page

TITLE="System Information for $HOSTNAME"

CURRENT_TIMESTAMP=$(date +"%x %r %Z")
TIME_STAMP="Generated $CURRENT_TIMESTAMP, by $USER"

report_uptime () {
    cat <<- _EOF_
        <H2>System Uptime</H2>
        <PRE>$(uptime)</PRE>
        _EOF_
    return
}

report_disk_space () {
    cat <<- _EOF_
        <H2>Disk Space Utilization</H2>
        <PRE>$(df -h)</PRE>
        _EOF_
    return
}

report_home_space () {
    cat <<- _EOF_
        <H2>Home Space Utilization</H2>
        <PRE>$(du -sh /home/*)</PRE>
        _EOF_
    return
}

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_

1 个答案:

答案 0 :(得分:1)

您可能使用空格而不是制表符&lt;&lt; - 不适用于空格。