Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

explanation about EOF pls... 3

Status
Not open for further replies.

adaaje

Technical User
May 26, 2006
60
AU
Hi guys,

I've got the code...
Code:
#!/bin/sh
echo 'what is the value? '
read value
cat <<EOF
The value is $value
EOF

what's the EOF means pls? and what does it do?
 
In this context, EOF can be any word.

They're called 'here' documents.

In short, it's an easy way of including short bits of text inside the shell script without having to do excessive amounts of quoting, and without having to create a separate file.

--
 
Thanks Salem,

Code:
#!/bin/sh
echo -n 'what is the value? '
read value
sed  's/XXX/'$value'/' <<EOF
The value is XXX
EOF

what about this ?? what the XXX means pls?

 
Are you sure this isn't homework??

Did you read and understand the link Salem posted?

XXX is nothing special, it's just a piece of text. The sed script is used to replace it with something else, in this case the contents of the value variable.

Annihilannic.
 
Hi

The content of the here-document is passed as input to the command on left side of the less-then signs ( < ).

So in the first code the [tt]cat[/tt] command get the text and output it. In the second code the [tt]sed[/tt] command get the text, execute the [tt]s///[/tt] command on the text, then output it.

If this was the missing chain.

Feherke.
 
Hi Annihilannic,

Thanks for being "nice", but I know that
sed 's/XXX/$value'

sed 's/[old pattern]/[new pattern]/'
is normally replacing XXX with $value,
but in this case $value replacing XXX

why?? that's the question ???
 
!??!?!! I'm sorry, I don't understand which part you don't understand. [3eyes]

"replacing XXX with $value" and "$value replacing XXX" means exactly the same thing?

Annihilannic.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top