On Sun, Jun 11, 2000 at 12:43:56AM -0800, Ethan Benson wrote: > On Sun, Jun 11, 2000 at 10:20:07AM +0200, Sven Burgener wrote: > > I've seen scripts like this and I'm wondering exactly what this line > > does: > > > > cat <<EOF > foo.scr > > > > I guess that up to the "EOF" it reads text and puts that into the named > > script..? EOF means EndOfFile, correct? Any refs for this? > > that is called a `here' document the << indicates that input should be > read until a certain keyword (in this case EOF) is found, then it > stops reading. > > EOF is common but not special, it can just as easily be FOE, FOO, BAR > etc, i don't think it even has to be all caps but that helps avoid > accidently catching something legitimate in the here document itself.
Amplifying slightly. Here documents are defined by the shell. The keyword is completely arbitrary, but EOF (end of file), END, LAST, etc., are common. Casing can be mixed. One semi-advanced feature people may not know of. Writing a here document as: cmd <<-KEYWORD ...strips leading tabs (but not blanks). This is to allow "natural" indenting of here documents in shell scripts. Some editors (eg: vi, vim, nvi) may replace tabs with some number of leading blanks. This is configurable behavior. -- Karsten M. Self <kmself@ix.netcom.com> http://www.netcom.com/~kmself Evangelist, Opensales, Inc. http://www.opensales.org What part of "Gestalt" don't you understand? Debian GNU/Linux rocks! http://gestalt-system.sourceforge.net/ K5: http://www.kuro5hin.org GPG fingerprint: F932 8B25 5FDD 2528 D595 DC61 3847 889F 55F2 B9B0
pgpw4SErZDIiB.pgp
Description: PGP signature