Append to a file text, a blank line, and the last line of another file

 $ echo -e "From: me\n\n$(tail -n1 /var/log/apache2/error.log)" >> file

— by kevin on June 21, 2012, 8:18 p.m.


  • -e option to echo makes it interpret '\n' as a newline
  • $(command) syntax runs a command, then uses its output in place


The -e flag of echo doesn't work on all systems. In that case you can use printf instead.