How to check if running in Cygwin, Mac or Linux?

后端 未结 11 895
忘掉有多难
忘掉有多难 2020-11-27 23:58

I have a shell script that is used both on Windows/Cygwin and Mac and Linux. It needs slightly different variables for each versions.

How can a shell/bash script de

11条回答
  •  生来不讨喜
    2020-11-28 01:05

    Use only this from command line works very fine, thanks to Justin:

    #!/bin/bash
    
    ################################################## #########
    # Bash script to find which OS
    ################################################## #########
    
    OS=`uname`
    echo "$OS"
    

    source

提交回复
热议问题