How to print value of a variable (which can be "-n" or "-e") in bash?

Posted by Vi on Stack Overflow See other posts from Stack Overflow or by Vi
Published on 2010-06-18T14:03:28Z Indexed on 2010/06/18 15:33 UTC
Read the original article Hit count: 108

Filed under:

How to print "-n", "-e" or "-neeenen" from bash (without a newline at the end, without invoking of external programs)?

Q="-n"

echo -n "$Q" # fail

echo -- "$Q" # fail

cat <<< "$Q" # fail, also starts external program

printf -- '%s' "$Q" # success, but starts external program

© Stack Overflow or respective owner

Related posts about bash