Shell Versions

Our exploration of extended shells brings up the good point that it's useful occasionally to be able to find the version number of various shells. Here's how:

$ bash --version                              
            bash
GNU bash, version 3.00.16(1)-release (i686-pc-linux-gnu)
...

$ ksh --version                               
            Recent ksh93 only
  version         sh (AT&T Labs Research) 1993-12-28 p

$ ksh                                         
            Older ksh
$ ^V                                          
            Type ^V
$ Version 11/16/88f                           ksh shows version

$ echo 'echo $KSH_VERSION' | pdksh            
            pdksh
@(#)PD KSH v5.2.14 99/07/13.2

$ echo 'echo $ZSH_VERSION' | zsh              
            zsh
4.1.1

There appears to be no way to get a version number from /bin/sh. This is not surprising. Most true Bourne shells on commercial Unix systems are descended from the System V Release 3 (1987) or Release 4 (1989) Bourne shell, and have changed little or not at all since then. Commercial vendors wishing to supply a POSIX-compliant shell generally do so by adapting some version of the Korn shell for that purpose.

Get Classic Shell Scripting now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.