Answer the question
In order to leave comments, you need to log in
Pretty way to specify string literals with control characters in bash?
It is required to use a string literal in bash containing, for example, a tab or newline. Here are the options I found.
Option 1:
x="hello
world"
x=`echo -e "hello\nworld"`
Answer the question
In order to leave comments, you need to log in
The answer was found in man bash.
You need to escape the string with single quotes and put $ in front of it:x=$'a\nb'
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question