M BUZZ CRAZE NEWS
// news

How to detect windows OS in shell script

By Joseph Russell

I would like to write a cross-platform script using shell so I can run it on linux, mac os and windows. I'm using cygwin on windows to make this possible. However, there are some custom commands that I need to execute on windows only. Is there a way to detect if the shell if running on windows in shell script? Thanks!

1 Answer

You can parse the output of the uname command to determine the underlying OS.

2

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy