echo doesn't work right

When you execute the script with shell command mode ( provide shell name), the shebang is ignored.

sh firstscript.sh , bash firstscript.sh , ksh firstscript.sh will execute the script in Bourne, Bash and Korn shell respectively. No matter what the shebang is.

1 Like

As scottn and alister suggested. Just use printf instead.

printf "Hello,world\a\n"

printf is standardized, whereas Posix echo does not include the -e option.

1 Like

Thank you very much.This help me a lot.:slight_smile:
And one more thing that puzzle me is when typing the following commands in bash

echo --version

screen output --version

echo --help

screen output --help

echo -h

screen output -h

You seem to have a penchant for non-standard commands. First echo -e, now print!

# echo $0
-bash

# print test
-bash: print: command not found

Why not just use printf and be done with it? In addition to portability you add flexibility.

Thank you for your suggestion.
I learn a lot of things from the reply of you kind mates.
I think it is worth learning because now I have a clearer pirture about what the stuff is going on.:slight_smile:

---------- Post updated at 03:53 AM ---------- Previous update was at 03:49 AM ----------

I'm sorry I didn't make the question clear,when I say print I mean the screen output.:stuck_out_tongue:

Ah, I see you updated your post.

My mistake. Need to get some coffee on the go :smiley: