How to input CRLF from keyboard in linux console

Solution 1:

Using vi, create a file having these two characters

  • vi file then i to enter input mode
  • Hit ^V followed by the decimal code of ^M:
  • ^V013 for CR
  • then save :wq since LF is automatically added by vi

If you have it (or install it) doing

hexdump -C file

should show

00000000  0d 0a                                             |..|

Now you can copy / paste or cat that file where necessary.

You could also prepare the file with other characters, headers that you cat one shot to your application.

Another, way is to install dos2unix (depending on your distrib), then prepare the file as necessary (ie without the CR aka ^M), then do

unix2dos file

and all 0a will be converted to 0d0a