Problem with echo command

I am trying to get ascii file using echo command, e.g. -

echo "\050"

It is correctly working on RHEL 4 but not in RHEL 5. Please help me to fix the issue.

## Working as expected in RHEL 4

$ lsb_release -d
Description:    Red Hat Enterprise Linux AS release 4 (Nahant Update 8)
$ echo "\050"
(
$

## Not working in RHEL 5

$ lsb_release -d
Description:    Red Hat Enterprise Linux Server release 5.7 (Tikanga)
$ echo "\050"
\050
$

Thanks
Atanu

Try:

printf "\050\n"

use echo -e "\050"

Some versions of echo interpet \050 by default, some don't.

Some versions of echo support -e, some don't.

Some shell builtin versions of echo have their own behavior, different from the external program's.

printf's behavior, on the other hand, is consistent almost everywhere -- so I recommend it instead of echo here.

1 Like

echo -e working on both the flavors (rhel 4 n 5), hence, I was thinking to replace "echo" with "echo -e". I have an (wrong) impression that after a small twist I would probably get expected behavior of echo - without using -e switch.

However, since Corona688 adviced printf has consistent behavior, I would probably go for replacing echo with printf.

Thank you very much guys for spending your time helping me to reach the conclusion.

Atanu