Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm on Debian Jessie. When I open a new textfile with mousepad and save it, then modify it with vim and save it again, I cannot print or grep the contents of it anymore.

If I do cat file, nothing is shown in the terminal. If I open file with vim or mousepad, I see the contents. If I write the file with vim, the following is shown in the status line:

"file" [mac] 2L, 5C written

While for a "normal" file, I only get

"file" 2L, 5C written

I thought the [mac] had something to do with the formatting of the new lines, so I tried to run:

dos2unix file

but the problem persists. Does anyone know what exactly is wrong with the file?

share|improve this question
vim actually has a built-in option for this. Simply run :set ff=unix to convert the file you are currently editing to use LF-only line endings. Then, overwrite the file with :w. – HalosGhost Jul 12 '14 at 11:25
up vote 7 down vote accepted

Use recode, e.g.: recode /cr file

Note: the fact that you can see the contents in the terminal with cat file is that the Mac end-of-line is CR, which puts the cursor at the beginning of the line without going to the next line, so that everything gets overwritten.

share|improve this answer
I'm wondering why the OP had the pre OSX old Mac CR format in the first place given that he's on Debian; a misconfiguration of mousepad perhaps? – Nick Jul 12 '14 at 15:52

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.