Hello,
I'm trying to use echo in a script and it isn't working according to the man page. My demo script is as follows:
Code:
#! /bin/sh
echo -e -n "hello\nworld\n"
echo -n -e "hello\nworld\n"
echo -n "hello\nworld\n"
echo -e "hello\nworld\n"
And it outputs:
Code:
-e -n hello
world
-e hello
world
hello
world
-e hello
world
According to the manpage, I would expect -e to be a valid option and to be turned off by default (both of these things seem to be false here). Furthermore if I do the same in an interactive shell I get:
Code:
$ echo -e -n "hello\nworld\n"
hello
world
$ echo -n -e "hello\nworld\n"
hello
world
$ echo -n "hello\nworld\n"
hello\nworld\n$ echo -e "hello\nworld\n"
hello
world
just as I would expect. Piping the commands into bash also works as I would expect.
The command "which echo" returns "/bin/echo" from the script and from the interactive shell. I'm sure that I'm missing something here, but I can't for the life of me figure it out. Does anybody have any input? Thanks!
Bookmarks