append text to end of file with cat

Objective: Append multiline text with cat

Examples

Replace contents of /etc/apache2/mods-available/geoip.conf

cat <<'EOF' > /etc/apache2/mods-available/geoip.conf
<IfModule mod_geoip.c>
  GeoIPEnable On
  GeoIPScanProxyHeaders On
  GeoIPDBFile /opt/modsecurity/etc/GeoIP.dat MemoryCache
</IfModule>
EOF

Tell log rotate to start rotating the http log (this overwrites any existing file)

Overwrite File with multi-line text  

append text to end of file with cat

append text to end of file with cat

Q: What is this magical feature?

A: Here Documents

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.