Feedback

type to search

By: Asked

How to represent strings with control characters (like \n \t) in bash?

How to represent strings with control characters (like \n \t) in bash?

0

sumpfralle

Storing and handling these characters does not need any special care:

  TEXT=“foo\nbar”

Just printing it might feel complicated. “printf” is a good solution for this:

  printf “foo\nbar”

Another alternative is “echo -e” – but it is not portable.

or Cancel
You need to join Debian to complete this action, click here to do so.