Cannot cat or grep contents of file

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?

Asked By: pfnuesel

||

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.

Answered By: vinc17
Categories: Answers Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.