How can I print a newline as \n in bash?

BubuIIC

Basically I want to achieve something like the inverse of echo -e. I have a variable which stores a command output but I want to print newlines as \n.

Vytenis Bivainis

Here's my solution:

sed 's/$/\\n/' | tr -d '\n'

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How can I print a newline as \n in bash?

From Dev

How can I delete a trailing newline in bash?

From Dev

How can I print out all but the last n characters in bash?

From Dev

How can I print a newline without flushing the buffer?

From Dev

How can I print a string with newline without flushing the buffer?

From Dev

How can I delete a just-typed newline character in bash?

From Java

How can I replace a newline (\n) using sed?

From Dev

How can I get less to display \n as a newline?

From Dev

How can I replace a literal \n with a newline character? (on OS X)

From Dev

How to print "-n" without issuing a newline?

From Dev

How can I print "-n" with `echo`?

From Dev

bash: read: how to capture '\n' (newline) character?

From Dev

Should I use printf("\n") or putchar('\n') to print a newline in C?

From Dev

How can I print contents of file given filename as stdin in bash?

From Dev

How can I print contents of file given filename as stdin in bash?

From Dev

How can I print an array and add a string to each item in Bash

From Dev

Bash newline doesn't print

From Java

How can I echo a newline in a batch file?

From Dev

How can I suppress ending newline in write()?

From Dev

How can i remove a newline using ultraedit?

From Dev

How can I split a string by newline in Shopify?

From Dev

How can I replace a newline with sed?

From Dev

How can i remove a newline using ultraedit?

From Dev

How can I print this?

From Dev

Print \n newline as actual newline in python pdb

From Dev

How do I print output without a trailing newline in Rust?

From Dev

How do I print backslash followed by newline with printf?

From Dev

How do I print backslash followed by newline with printf?

From Dev

Print \n as actual newline in terminal

Related Related

  1. 1

    How can I print a newline as \n in bash?

  2. 2

    How can I delete a trailing newline in bash?

  3. 3

    How can I print out all but the last n characters in bash?

  4. 4

    How can I print a newline without flushing the buffer?

  5. 5

    How can I print a string with newline without flushing the buffer?

  6. 6

    How can I delete a just-typed newline character in bash?

  7. 7

    How can I replace a newline (\n) using sed?

  8. 8

    How can I get less to display \n as a newline?

  9. 9

    How can I replace a literal \n with a newline character? (on OS X)

  10. 10

    How to print "-n" without issuing a newline?

  11. 11

    How can I print "-n" with `echo`?

  12. 12

    bash: read: how to capture '\n' (newline) character?

  13. 13

    Should I use printf("\n") or putchar('\n') to print a newline in C?

  14. 14

    How can I print contents of file given filename as stdin in bash?

  15. 15

    How can I print contents of file given filename as stdin in bash?

  16. 16

    How can I print an array and add a string to each item in Bash

  17. 17

    Bash newline doesn't print

  18. 18

    How can I echo a newline in a batch file?

  19. 19

    How can I suppress ending newline in write()?

  20. 20

    How can i remove a newline using ultraedit?

  21. 21

    How can I split a string by newline in Shopify?

  22. 22

    How can I replace a newline with sed?

  23. 23

    How can i remove a newline using ultraedit?

  24. 24

    How can I print this?

  25. 25

    Print \n newline as actual newline in python pdb

  26. 26

    How do I print output without a trailing newline in Rust?

  27. 27

    How do I print backslash followed by newline with printf?

  28. 28

    How do I print backslash followed by newline with printf?

  29. 29

    Print \n as actual newline in terminal

HotTag

Archive