0

I use Ubuntu 18.04. When I run the a.sh file, the -e option is written to the a file. I have thought of many other methods, but I can't solve it, so I ask.

# uname -a
Linux psh 5.4.0-60-generic #67~18.04.1-Ubuntu SMP Tue Jan 5 22:01:05 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

# echo $SHELL
/bin/bash

Why is the -e option written to the a file?

# cat a.sh
echo -e "abc" > a

# cat a
-e abc
P.Lonnie
  • 105
  • 2
  • 11
  • How did you execute `a.sh`? Anyway, your bash thinks it should behave like `sh`, and that one's echo doesn't understand `-e`, so it echos it out, too. Try `bash a.sh`, or att `#!/bin/bash` as the first line of your script. – tink Jan 30 '21 at 02:04
  • You are using a shell that does not support options to `echo`. Please use `printf` instead. Options to `echo` are not portable. – costaparas Jan 30 '21 at 02:10
  • `echo $SHELL` does not tell you which shell a script will be executed with – that other guy Jan 30 '21 at 04:01

0 Answers0