title: How do I cat multi-line content to a file in a systemd unit file?
body: <p>I am trying to write a file to disk as part of the <code>ExecStartPre</code> command of a systemd unit file.</p>
  
  <p>This is what I am using:</p>
  
  <pre><code>[Unit]
  Description=My service
  
  [Service]
  Restart=always
  StartLimitInterval=0
  ExecStartPre=/usr/bin/cat &lt;&lt;EOFDefaults &gt; /tmp/test
  option1=value1
  option2=value2
  EOFDefaults
  
  ExecStart=/run/some/command
  </code></pre>
  
  <p>Since that's a multi-line command, I get the following error when testing it with <code>systemd-analyze verify myservice.service</code>.</p>
  
  <p>So, I tried to escape the multi-lines:</p>
  
  <pre><code>[Unit]
  Description=My service
  
  [Service]
  Restart=always
  StartLimitInterval=0
  ExecStartPre=/usr/bin/cat &lt;&lt;EOFDefaults &gt; /tmp/test \
  option1=value1 \
  option2=value2 \
  EOFDefaults
  
  ExecStart=/run/some/command
  </code></pre>
  
  <p>When testing the unit file, I get the following error: <code>Invalid escape sequences in command line:</code></p>
  
  <p>How does one use cat to write multi-line content to a file as part of a systemd unit file command?</p>