line 1: syntax error near unexpected token `newline' with HTML + shell script I've been learning the shell with a great tutorial, linuxcommand.org. After a lot of learning and practice with navigating directories, editing files, etc, I've moved on to writing shell scripts.

One of the first tutorials linuxcommand.org has is using HTML in a shell script to return some system info. You can check it out here . I'm currently on the 'Command Substitution and Constants' section. 

One of the first things in the tutorial said the file could be used by redirecting the standard output to .html:


  
    ~me$ ./sysinfo_page > sysinfo_page.html
  


my script looks exactly like the one on the link, but I'll post it anyway:

(the only difference is linux uses the env var $HOSTNAME, I'm on OS X and it's $LOGNAME)

#!/bin/bash

# sysinfo_page - Generate an HTML page based on system information

title="My System Information"
RIGHT_NOW=$(date +"%x %r %Z")
TIME_STAMP="Updated on $RIGHT_NOW by $USER"

cat &lt;&lt;- _EOF_
    &lt;html&gt;
    &lt;head&gt;
        &lt;title&gt;
        $title $LOGNAME
        &lt;/title&gt;
    &lt;/head&gt;

    &lt;body&gt;
        &lt;h1&gt;$title $LOGNAME&lt;/h1&gt;
        &lt;p&gt;$TIME_STAMP&lt;/p&gt;
    &lt;/body&gt;
    &lt;/html&gt;
_EOF_


When I type into the command line:


  
    ~me$  ./sysinfo_page
  


it gives me the contents of only the HTML, but it isn't formatted and still displays the tags. I'm assuming that by redirecting the standard output to a .html extension would give me the formatted HTML page, without the tags but I wouldn't know because, after giving chmod rwx permission with 755, I type:


  
    ~$me  ./sysinfo_page.html
  


And get this error: 

./sysinfo_page.html: line 1: syntax error near unexpected token `newline'
./sysinfo_page.html: line 1: `&lt;html&gt;'


I understand by what I've read that &lt; > indicates a placeholder, but that's the HTML syntax...and exactly how it works on the tutorial. I thought maybe adding a &lt;!DOCTYPE&gt; would fix it, but didn't. My question is, what am I doing wrong here? How can I get it to display the HTML page correctly?
HTML is not a script, it's a markup language. You need a browser to render HTML. To view it, you probably want

open sysinfo_page.html