On Thu, Mar 02, 2006 at 02:41:08PM +0800, LUK ShunTim wrote: > <script1> > cat <<EOF >>outfile > Some words > EOF > </script1> > > works but when it is embedded inside an if-then-fi construct like, > > <script2> > AAA="" > if [ -z "$AAA" ]; then > cat <<EOF >>outfile > Some words > EOF > fi > </script2> > > it fails with error message > "script2: line 7: syntax error: unexpected end of file" > > What have I missed?
It's not the if-then-fi causing your problem, but the indentation within. Lose the leading spaces in the here text (unless you want your outfile to contain " Some words" rather than "Some words") and the limit string ("EOF"). See <http://www.tldp.org/LDP/abs/html/here-docs.html#INDENTEDLS> HTH dt -- Dave Thayer | Whenever you read a good book, it's like the Denver, Colorado USA | author is right there, in the room talking to [EMAIL PROTECTED] | you, which is why I don't like to read | good books. - Jack Handey "Deep Thoughts" -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]