AIX to Linux command difference

Moving from AIX 6.1 to RHEL 6.6, I have noticed a few command differences.
One that has been causing issue is a simple echo command when I have to use it this way ->

"echo -e"

On the AIX it outputs to "-e" but since RHEL has "-e" as an option for echo and hence it outputs to blank here.
All the code needs to be updated unless anyone here has a better option that you may have found in similar scenario.
Please suggest.

Use ksh instead bash . You are probably used to ksh anyway when you come from AIX and it is available on every Linux since some time now. When using ksh you have the shell-internal " print " for output. It allows to explicitly end options by using a single dash:

print -u2 "foo bar"

will output "foo bar" to stderr (-u2) but:

print - -u2 "foo bar"

will write "-u2 foo bar" to stdout , because "-u2" is no longer considered an option.

Per default i use it that way, especially if i do not know what a variable i want to display contains:

print - "$var"

Even if "$var" contains options to "print" they will be ignored.

I hope this helps.

bakunin

Ok... so in general we have an old SysV vs. Berkley... or perhaps a ksh vs. Berkley-ism.

I too was somewhat displeased with the Linux choice of a BSD-ish like echo since it tried to be more POSIX which made is smell more SysV like (Linux is sort of its own blend).

So the niceness of echo "first line\nsecond line" that you had in HPUX, Solaris, etc.. well, you had to do echo -e "first line\nsecond line" in Linux. Now... with more contemporary versions of ksh, they've added a "do nothing" option of -e, which means for any system running ksh93 (maybe even something less) but not not a really old ksh, you could use -e to make scripts seemingly portable.

But... maybe you plan to run ksh93 on your Linux host.

Then, you can run the following:

$ builtin getconf
$ getconf UNIVERSE = att
$ echo "hello\n\nthere"
hello

there
$

Sadly, even getconf syntax has changed over the years, for the command getconf UNIVERSE = att, you may have to use a minus instead of an equals.... :slight_smile:

Now... with regards to that latter solution, if you whole system runs in ksh and uses a non-systemd SysV style init, you could put that stuff there, but of course I can pretty much guarantee you that your distro producers didn't have portability in mind when they wrote their init scripts. So... it will likely render your system useless to try change away from bash.

There's like a KSHENV var that might be able to pull such things in for any ksh script..... it's been too long.. anyhow, might get you pointed in the right direction.

bakunin - That is the excat change I am trying to avoid as it involves many script changes.
Our scripts have something like

 Options -a Call All
-e Call event
-t time specific

Now when this script is called in command line, its like

 asd.ksh -e EVENT -t 2200 

inside the script we check as below

"var = 'echo $1'"

This is where the problem arises.

cjcox - Thanks a lot for those inputs...I will try to research more on those lines.