1

When run ls to print the file list

#+begin_src ipython :session sql :results output
! ls | head -n 5


#+end_src

#+RESULTS:
: create.txt^M
: Lesson 10. Grouping Data.md^M
: Lesson 11. Working with Subqueries.md^M
: Lesson 12. Joining Tables.md^M
: Lesson 13. Creating Advanced Joins.md^M

There are always ^M characters appended,

My machine info:

$ uname -a
Linux alpha 5.3.0-24-generic #26-Ubuntu SMP Thu Nov 14 01:33:18 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

How can I disable such a line-ending representation?

My machine is " Distributor ID: Ubuntu Description: Ubuntu 19.10 Release: 19.10 Codename: eoan "

Alice
  • 219
  • 1
  • 7

1 Answers1

2

Those Control-M characters (^M) are no doubt end-of-line chars used by your OS - probably MS Windows.

(Please provide your OS/platform in the question. And if it's Windows then state how you are using OS command ls - e.g., Cygwin, ls-lisp.el, or something else.)

You can control this ^M display using the buffer coding for line endings. Something like this might be all you need:

(setq-default buffer-file-coding-system (coding-system-change-eol-conversion
                                         (default-value 'buffer-file-coding-system)
                                         'unix))

But for more information, see these nodes in the Emacs manual:

Drew
  • 75,699
  • 9
  • 109
  • 225
  • My machine is " Distributor ID: Ubuntu Description: Ubuntu 19.10 Release: 19.10 Codename: eoan " – Alice Dec 22 '19 at 02:24
  • Please put all such info in the question itself. Comments can be deleted at any time. Thx. – Drew Dec 22 '19 at 17:51