Friday, October 28, 2022

[SOLVED] convert \n (end-of-line) instruction to actual end of line

Issue

I have a file exported from a mysql database which include \n (literally) for end-of-line. This file is composed of one line only because the end-of-line symbol is not interpreted

my file is like this \n there is another line \n and I would like "\n" to be interpreted

How can I replace \nwith a actual new line?

There are a lot of answer to this question with notepad++ but I am on Linux. I tried this solution with emacs but C-q C-j did not create a new line in my buffer.


Solution

(replace-string "\\n" "\n")

If you are looking for an interactive keyboard sequence, try M-% \ n C-j RET ! (but realize that Stack Overflow is for programming questions).

If you are on some godforsaken platform where C-j doesn't emit a newline, try C-q C-j or the octal sequence C-q 0 1 2 (recall that LF is octal 012).



Answered By - tripleee
Answer Checked By - Senaida (WPSolving Volunteer)