Substitua novas linhas por literal \ n

Esta questão de stackoverflow tem uma resposta para substituir as novas linhas por sed, usando o formato sed ': a; N; $! ba; s / \ n / / g'.

Isso funciona, mas não para caracteres especiais como \ r, \ n etc.

O que estou tentando fazer é substituir o caractere de nova linha por um literal \ n. Tentou

sed ':a;N;$!ba;s/\n/\\n/g'

e

sed ':a;N;$!ba;s/\n/\\\n/g'

Além disso

sed ":a;N;$!ba;s/\n/'\'n/g"

Mas tudo em vão. O Sed continua substituindo o caractere de nova linha .... por um caractere de nova linha.

Pensamentos?

Editado após a primeira resposta:

Por uma questão de integridade, os comandos executados são:

PostContent =cat $TextTable | sed -E ':a;N;$!ba;s/\r{0,1}\n/\\n/g'

Onde TextTable é uma variável vinculada a um arquivo de texto que contém uma saída JSON no seguinte formato:

{"posts":[{"title":"mysupertest","slug":"bi-test","markdown":"##TEST
First things first !
To TEST this TEST TEST, click the download button below.
If you need more information about the TEST TEST, you can  read the Table of Contents below.

<a href='/assets/TEST.pdf' style='border-radius:5px; padding: 4px 15px; background-color:#008CBA; color:white; text-decoration:none; float:right;' download> Download </a>


##TEST OF TEST


###TEST TEST PLATFORM TEST GUIDE
WaTESTve TEST SetupTEST
TESTTEST
TESTTESTETESTTETSTTEST
TESTTESTTTETST
TESTTES
TESTTESTESSTSTESTESTTES
TEST","image":"http://localhost:3000/myimage.jpg","featured":false,"page":false,"status":"draft","language":"en_US","meta_title":null,"meta_description":null,"author":"4","publishedBy":null,"tags":[{"uuid":"ember2034","name":"implementation guides","slug":null,"description":null,"meta_title":null,"meta_description":null,"image":null,"visibility":"public"}]}]}

questionAnswers(4)

yourAnswerToTheQuestion