Is there a command called print in Bourne shell?

Environment : HP-UX (sorry :smiling_face: )

Since I came across print command being used in shell scripts in this HP-UX server, I looked for print command in the command line.
It turns out there is a print command in Bourne shell, at least in HP-UX.

But, I don't see print command in $PATH. It is not an alias either. type command's output says it is a shell builtin.

echo $0 revealed that the shell is Bourne shell. So, is there a command called print in Bourne shell ?

$ uname -a
HP-UX myhostname B.11.31 U ia64 2380116268 unlimited-user license

$ print hello world
hello world
$
$
$ ## It is not in $PATH
$ which print
no print in /usr/sbin /usr/bin /usr/ccs/bin /usr/contrib/bin . /opt/nedit-5.5-HPUX/bin /opt/cfg2html /opt/nettladm/bin /opt/fcms/bin /opt/wbem/bin /opt/wbem/sbin /opt/sas/bin /opt/wli/bin /opt/graphics/common/bin /opt/resmon/bin /usr/contrib/kwdb/bin /usr/bin/X11 /usr/contrib/bin/X11 /opt/prm/bin /opt/propplus/bin /opt/sfm/bin /opt/swm/bin /opt/ssh/bin /opt/hpsmh/bin /opt/firefox /usr/local/sbin /usr/local/lbin /usr/local/bin /opt/langtools/bin /opt/ignite/bin /opt/perf/bin /opt/dsau/bin /opt/dsau/sbin /opt/gvsd/bin /opt/ipf/bin /opt/hpvm/bin /opt/atok/bin /opt/sec_mgmt/bastille/bin /opt/caliper/bin /opt/drd/bin /etc/cmcluster/scripts/tkit/vtn /opt/perl_32/bin /opt/perl_64/bin /opt/sec_mgmt/spc/bin /opt/swa/bin /opt/thunderbird /opt/sentinel/bin /opt/wlm/bin /opt/gwlm/bin /sbin /root /opt/bin /opt/quest/bin /opt/oracle/base/admin/oramgr/bin /usr/local/bin /usr/local/lbin /usr/sbin /opt/iexpress /opt/oracle/agent/agent_inst/bin /opt/iexpress/curl/bin

# echo is in the $PATH though.
$ which echo
/usr/bin/echo

$
$ alias | grep -i print
vxprint=/usr/sbin/vxprint
$
$
$ type print
print is a shell builtin.
$
$ man print
No manual entry for print.
$
$ echo $0
-sh
$
$ echo $SHELL
/usr/bin/sh
$ file /usr/bin/sh
/usr/bin/sh:    ELF-32 executable object file - IA64
$

which is a csh (and tcsh) builtin.
So it can only find external commands (and csh builtins).
I do not recommend which in other shells.
type is a Bourne- and standard-shell builtin.
print is a ksh builtin. In HP-UX /bin/sh is a link to ksh, therefore it works there, but this is not the case on other OS.
Only Solaris (10 and older) has got the (old poor) Bourne shell. Usually /bin/sh is a Posix shell that is highly compatible with Bourne but more powerfull. On some Linux distros /bin/sh is a link to bash, that when called as sh is highly compatible with Posix shell.

2 Likes

Hi,

One slight addendum to this: I believe that from version 10 onwards, the default shell in HP-UX is actually the POSIX shell. Prior to that, it was the Korn shell, as MadeInGermany rightly says. Since you're on 11.31 from the info you posted, I suspect that your /bin/sh is the POSIX shell, which is what HP switched to using a little while back as the default. But on HP-UX prior to 10.0, the default shell is indeed Korn.

1 Like

ITYM Bourne shell.?
Korn shell is ksh.

ksh88 in sh mode was Posix certified. But is not a true psh.

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.