1

This question already has an answer here:

How do I add a new empty line to the beginning of a file under MacOS and Linux?

I have tried the below command and it produces a new line character under MacOS

sed -i.bak '1s/^/TESTe\n/' test.py

marked as duplicate by Kusalananda, Michael Homer, Costas, countermode, GAD3R Jan 25 '17 at 10:36

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • can you show what output you got? and what is expected output? – user13107 Jan 25 '17 at 4:20
  • 2
    I'm not familiar with osx, but I'd suggest you use the i (insert) command rather than the s (substitute) command - that way, you should be able to avoid the need to specify an explicit line termination – steeldriver Jan 25 '17 at 4:27
  • cp test.py test.py.bak && (echo TESTe; cat test.py.bak) >test.py – Satō Katsura Jan 25 '17 at 7:15
  • A Linux solution is sed -e '1s/^/\n/' filename – Zumo de Vidrio Jan 25 '17 at 7:55

Browse other questions tagged or ask your own question.