What does EOFD mean?

Go To StackoverFlow.com

4

While browsing SO I sometimes see EOFD for example:

ftp -vn <$hostname> <<EOFD

Yes I tried Google with no luck, just in case you are wondering.

2012-04-04 22:26
by jdorfman
dunno about D. But EOF = End Of Fil - hjpotter92 2012-04-04 22:28
End OF Data, maybe? The identifier used in a here document can be anything you like - Keith Thompson 2012-04-04 22:28
as @blahdiblah pointed out I was referencing this questionjdorfman 2012-04-04 23:44
EOF stands for end-of-file the <<xxx is a delimiter for a here-document so perhaps EOFD stands for end-of-file delimiter or end-of-file data - potong 2012-04-05 06:40


5

In the context of the question you reference, EOFD doesn't mean anything special, it's just the start of a bash here document.

From the Advanced Bash-Scripting Guide:

A here document is a special-purpose code block. It uses a form of I/O redirection to feed a command list to an interactive program or a command, such as ftp, cat, or the ex text editor.

COMMAND <<InputComesFromHERE
...
...
...
InputComesFromHERE

A limit string delineates (frames) the command list. The special symbol << precedes the limit string. This has the effect of redirecting the output of a command block into the stdin of the program or command. It is similar to interactive-program < command-file, where command-file contains

command #1
command #2
...

The here document equivalent looks like this:

interactive-program <<LimitString
command #1
command #2
...
LimitString

Choose a limit string sufficiently unusual that it will not occur anywhere in the command list and confuse matters.

So in that question, the author was sending commands to ftp as if using it interactively.

2012-04-04 22:48
by blahdiblah
Makes sense, thanks so much - jdorfman 2012-04-04 23:40


3

Try again with these search terms: here document

2012-04-04 22:28
by C2H5OH


3

The <<EOFD construct is a special type a redirection for shell scripts (Bourne, bash and I'm not sure what others) that tell the shell to treat the lines follow as the stdin stream until a line that consists of EOFD is seen.

The EOFD string is arbitrary - any unique token (or at least one that won't be in the stdin input stream).

2012-04-04 22:32
by Michael Burr


1

Since these words are arbitrary, why would anyone write EOFD rather than the customary EOF?

(And, by the way, there is also the tradition of using the ! character:

cat <<!
Hello
world
!

)

EOFD might be useful if the text you're generating with a here document is itself a shell script which itself contains here documents, and those here documents already use EOF for delimiting:

cat <<EOFD
#!/bin/sh
# here doc script
cat <<EOF
Hello
World
EOF
EOFD

:)

2012-04-05 01:15
by Kaz
I have not seen the ! tradition (that I recall anyway). EOF and end (in upper and lower case) are pretty common, and some people use different end markers for each here-document in a script, presumably to make them easier to find - torek 2012-04-05 02:07
Ads