Shell script with string beginning with "-e" Shell script with string beginning with "-e" unix unix

Shell script with string beginning with "-e"


echo is not a very good UNIX citizen. If it were well-behaved you'd be able to write echo -- "$STR", with -- indicating the end of the options list. But it's not, so you can't.

Your best bet is to use printf instead.

printf '%s\n' "$STR"