isunix

Tests whether the program runs on a Unix-based system such as Linux or macOS.

Category: Environment and Settings > Platform and License

Syntax

tf = isunix

Returns true on Linux or macOS and false on Windows.

Description

isunix groups every system that is not Windows, including macOS. To tell Linux from macOS, combine it with ismac: isunix && ~ismac. It is commonly used before calling shell commands such as ls.

Output arguments

tf
Logical scalar.

Example

Windows and Unix are exclusive

tf = isunix;
class(tf)
ispc ~= isunix
Output
ans = 'logical'
ans = logical
   1

See also

ispc ismac computer system