# unix

## Purpose

Execute a UNIX command from MATLAB.

## Synopsis

    unix('command')
    [status,output] = unix('command')

## Description

`unix('command')` executes a UNIX operating system command. The statement returns the resulting status as an integer and the standard output in a string variable.

## Examples

`[s,w] = unix('who')` returns `s = 0` and, in `w`, a MATLAB string containing a list of users currently logged in.

    s =
        0

    w =

    gulley   console Apr 13 09:32
    joe      ttyp0   Apr 13 09:02
    sully    ttyp2   Apr 13 09:37
    gulley   ttyp2   Apr 13 09:37
    gulley   ttyp3   Apr 13 09:34
    marianne ttyp4   Apr 13 10:43

If the UNIX command fails, MATLAB returns a nonzero status value. For example,

    [s,w] = unix('why')
    why: Command not found.

    s =
        256

    w =
        []

## See Also

    !

(c) Copyright 1994 by The MathWorks, Inc.