UKB UKB - 4 years ago 163
Bash Question

Create file with contents from shell script

How do I, in a shell script, create a file called foo.conf and make it contain:

NameVirtualHost 127.0.0.1

# Default
<VirtualHost 127.0.0.1>
ServerName localhost
DocumentRoot "C:/wamp/www"
</VirtualHost>

ams ams
Answer Source

Use a "here document":

cat > foo.conf << EOF
NameVirtualHost 127.0.0.1

# Default
<VirtualHost 127.0.0.1>
ServerName localhost
DocumentRoot "C:/wamp/www"
</VirtualHost>
EOF
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download