How can I find my shell version using a Linux command?

前端 未结 4 2140
说谎
说谎 2021-02-01 03:42

I would like to know about my shell version using a Linux command. I tried the following command, but it shows the type of the shell I am in.

Command:

ec         


        
4条回答
  •  独厮守ぢ
    2021-02-01 04:03

    There is a case when your shell does not have a command line parameter to determine the version directly. This case is Bourne shell. For Bourne shell I would recommend to use a script: https://www.in-ulm.de/~mascheck/various/whatshell/whatshell.sh. The script is pretty small so that it is not a big trouble to review it and understand how it is working. I have tested this script inside different shells on Linux and Solaris and it always gave the shell version for me.

    Some examples:

    Ubuntu 18.04

    $ sh -c './whatshell.sh'
    ash (Busybox 1.x)
    $ bash -c './whatshell.sh'
    bash 4.4.19(1)-release
    

    CentOS 4

    $sh -c './whatshell.sh'
    bash 3.00.15(1)-release
    

    Solaris 10

    ~> sh -c './whatshell.sh'
    ksh88 Version (..-)11/16/88i (posix octal base)
    ~> bash -c './whatshell.sh'
    bash 4.1.7(3)-release
    ~> csh -c './whatshell.sh' 
    SVR4 Bourne shell (SunOS 5 variant)
    

    AIX 6.1

    ~> sh -c './whatshell.sh'
    ksh88 Version (..-)11/16/88f
    ~> bash -c './whatshell.sh'
    bash 4.2.0(1)-release
    

    This is also answers for the question Bourne shell version which was marked as off topic.

提交回复
热议问题