Take the 2-minute tour ×
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.

In VMS DCL one may embed data in a command file using $DECK and $EOD. What is Linux for this?

share|improve this question
    
It may be worth explaining in a little more detail how $DECK/$EOL work –  Brian Agnew Jun 14 '09 at 15:06
    
Would someone who has a VMS system add to the question an example that matches the "cat sample.txt << EOF" answer? –  C.W.Holeman II Jun 14 '09 at 15:21
add comment

migrated from stackoverflow.com Feb 12 '11 at 20:23

This question came from our site for professional and enthusiast programmers.

2 Answers

up vote 7 down vote accepted

You can embed data within shell scripts. How this works is shell dependent. However bash/perl etc. do this in similar ways, using a heredoc. e.g. in bash (and similar):

$ cat > sample.txt << EOF
a
b
c
EOF

will write as input a,b,c up to the EOF, and then cat will write that out to sample.txt. Note that EOF is a convention and you can use any label. Try the above on the command line to see more clearly what's going on.

share|improve this answer
add comment

Loki also made a tool called makeself. This tool can embed compressed data in a shell file and is useful for self-extracting installation scripts.

share|improve this answer
add comment

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.