---------- Post updated at 11:49 AM ---------- Previous update was at 11:43 AM ----------
Yes, in the description it says
-e enable interpretation of backslash escapes
And when I type the command directly in the shell,it work right!
So weird!
was to see if $PATH is different in your shell and your script. (eg you have a PATH setting in your shell which isn't exported to your script) if the command above returns different values for both then call the command in the script using the full path name returned in the shell, where it worked.
Amen to what scottn said. You'll see echo in many scripts so you should be familiar with it, but echo with any options is not portable. Do yourself a favor and learn your way around the printf(1) command (usually a shell-builtin).
Regarding your problem, perhaps your environment has aliased echo or has defined a function that overrides the builtin. In bash, the following command would indicate exactly what your shell is trying to execute (whether you type it at the command line or in a script):
type echo
Regards,
Alister
---------- Post updated at 04:05 PM ---------- Previous update was at 03:58 PM ----------
When the first word contains slashes, the shell attempts to execute the executable at that location; when the first word does not contain slashes, the shell goes through a lookup process that checks for the existence of functions and builtins before it tries a $PATH lookup. In either case, aliases are expanded beforehand.
GNU bash, version 4.1.5(1)-release (i686-pc-linux-gnu)
---------- Post updated at 08:09 PM ---------- Previous update was at 07:53 PM ----------
Regarding your problem, perhaps your environment has aliased echo or has defined a function that overrides the builtin. In bash, the following command would indicate exactly what your shell is trying to execute (whether you type it at the command line or in a script):
type echo
Regards,
Alister
Both return echo is a shell builtin
Plus,when I type the command
echo --version
in bash it return
--version
when I type
echo --help
int bash it return
--help
But when I type /bin/echo instead of echo,everything goes right.
Anything difference between the builtin echo and the /bin/echo?