I want to echo a string that might contain the same parameters as echo. How can I do it without modifying the string?
For
Try the following:
$ env POSIXLY_CORRECT=1 echo -e
-e
Due to shell aliases and built-in
echocommand, using an unadornedechointeractively or in a script may get you different functionality than that described here. Invoke it viaenv(i.e.,env echo ...) to avoid interference from the shell.The environment variable
POSIXLY_CORRECTwas introduced to allow the user to force the standards-compliant behaviour. See: POSIX at Wikipedia.
Or use printf:
$ printf '%s\n' "$var"
Source: Why is bash swallowing -e in the front of an array at stackoverflow SE