2019-03-31 09:05:09 +00:00
|
|
|
.. _cmd-eval:
|
|
|
|
|
2018-12-17 01:39:33 +00:00
|
|
|
eval - evaluate the specified commands
|
2019-01-03 04:10:47 +00:00
|
|
|
======================================
|
2018-12-17 01:39:33 +00:00
|
|
|
|
2018-12-18 01:58:24 +00:00
|
|
|
Synopsis
|
|
|
|
--------
|
2018-12-16 21:08:41 +00:00
|
|
|
|
2021-12-17 21:58:38 +00:00
|
|
|
**eval** [*COMMANDS*...]
|
2018-12-18 01:58:24 +00:00
|
|
|
|
2018-12-19 02:44:30 +00:00
|
|
|
Description
|
2019-01-03 04:10:47 +00:00
|
|
|
-----------
|
2021-12-17 21:58:38 +00:00
|
|
|
**eval** evaluates the specified parameters as a command.
|
|
|
|
If more than one parameter is specified, all parameters will be joined using a space character as a separator.
|
2018-12-16 21:08:41 +00:00
|
|
|
|
2021-12-17 21:58:38 +00:00
|
|
|
If the command does not need access to stdin, consider using :ref:`source <cmd-source>` instead.
|
2018-12-16 21:08:41 +00:00
|
|
|
|
2019-11-18 15:02:21 +00:00
|
|
|
If no piping or other compound shell constructs are required, variable-expansion-as-command, as in ``set cmd ls -la; $cmd``, is also an option.
|
2018-12-16 21:08:41 +00:00
|
|
|
|
2019-04-26 13:30:13 +00:00
|
|
|
Example
|
|
|
|
-------
|
2018-12-19 03:14:04 +00:00
|
|
|
|
2019-04-26 13:30:13 +00:00
|
|
|
The following code will call the ls command and truncate each filename to the first 12 characters.
|
2018-12-19 03:14:04 +00:00
|
|
|
|
|
|
|
::
|
|
|
|
|
2019-04-26 13:30:13 +00:00
|
|
|
set cmd ls \| cut -c 1-12
|
2018-12-19 03:14:04 +00:00
|
|
|
eval $cmd
|
|
|
|
|