Sign up ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

I have this script (it is actually a snippet from a bigger script).

#!/bin/sh

 if [ $actualsize -ge $MAXSIZE ]; then
  read dummy FILEPOINT <<EOF
  `dd if=myfile skip=8001 count=1 bs=1|od -x`
  EOF
 fi

When I run it, I get

./bugged.sh: 9: Syntax error: end of file unexpected (expecting "fi")

Apparently, the problem is the "EOF". Why does this happen and how can I achieve the same result (reading from myfile)?

share|improve this question

2 Answers 2

up vote 6 down vote accepted

Either stop indenting the EOF, or use <<-EOF earlier and indent it using tabs.

share|improve this answer

Ignacio explained the error you get, but you may want to simplify your code and avoid the here document in the first place like:

filepoint=$(od -An -j 8001 -N 1 -t x1 < myfile)
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.