Thread: cat << EOF
View Single Post

   
  #10 (permalink)  
Old 02-20-2008, 08:08 AM
+Alan Hicks+
 
Posts: n/a
Default Re: cat << EOF

Lew Pitcher <Lew.Pitcher@td.com> trolled:

pgp trash troll delete

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> ray wrote:
>> simple question...
>>
>> cat << EOF
>> foo
>> bar
>> EOF
>>
>> echos foo and bar...
>>
>> The question is - is that the shell (bash) or ??? that supports that
>> function?
>>
>> Simple question I'm sure, but googling for << doesn't work....
>>
>>
>> Either zsh supports that as well or it's not bash... I'm confused.

>
> It's called a "here document". Google for that term, and you'll get a
> much better explanation than I can give.
>
> But, in brief
> it is a feature of the shell; bash supports it, and (apparently) so does
> zsh.
>
> The construct
> <<something
> data
> data
> something
>
> tells the shell to collect all the lines following the <<something, up
> to but not including the trailing 'something' and feed that data into
> the processes stdin.
>
> Shell variable expansion will be performed, given the suitable set up of
> your shell.
>
> So, for instance,
> DATE=`date`
> cat >/etc/issue.net <<EOF
> Hello there. This file was built on $DATE
> You have reached my system. Nice, isnt it?
> EOF
>
> will expand the $DATE field, and copy the resulting text into your
> /etc/issue.net file
>
> See bash(1) for details
> You might also read http://www.faqs.org/docs/abs/HTML/here-docs.html
>
>
>
>
> - --
>
> Lew Pitcher, IT Specialist, Enterprise Data Systems
> Enterprise Technology Solutions, TD Bank Financial Group
>
> (Opinions expressed here are my own, not my employer's)
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.2.4 (MingW32)
>
> iD8DBQFCpcxBagVFX4UWr64RAtZOAKDaUuMJ0VlaDKv0blEIHx zAUeKp5wCfciyr
> t5H9+178SZVGPkQggFx/gFw=
> =gc6C
> -----END PGP SIGNATURE-----

_________________________________________
Usenet Zone Free Binaries Usenet Server
More than 120,000 groups
Unlimited download
http://www.usenetzone.com to open account
Reply With Quote