| MATLAB Function Reference | ![]() |
Execute a UNIX command and return result
Syntax
unix command
status = unix('command')
[status,result] = unix('command')
[status,result] = unix('command','-echo')
Description
unix command
calls upon the UNIX operating system to execute the given command.
status = unix('command')
returns completion status to the status variable.
[status, result] = unix('command')
returns the standard output to the result variable, in addition to completion status.
[status,result] = unix('command',' forces the output to the Command Window, even though it is also being assigned into a variable.-echo')
Examples
List all users that are currently logged in. It returns a zero (success) in s and a string containing the list of users in w.
The next example returns a nonzero value in s to indicate failure and returns an error message in w because why is not a UNIX command.
When including the -echo flag, MATLAB displays the results of the command in the Command Window as it executes as well as assigning the results to the return variable, w.
See Also
dos, ! (exclamation point), perl, system
| unique | unmkpp | ![]() |