2019-03-31 17:05:09 +08:00
.. _cmd-eval:
2018-12-17 09:39:33 +08:00
eval - evaluate the specified commands
2019-01-03 12:10:47 +08:00
======================================
2018-12-17 09:39:33 +08:00
2018-12-18 09:58:24 +08:00
Synopsis
--------
2018-12-17 05:08:41 +08:00
2019-09-17 17:59:04 +08:00
::
eval [COMMANDS...]
2018-12-18 09:58:24 +08:00
2018-12-17 05:08:41 +08:00
2018-12-19 10:44:30 +08:00
Description
2019-01-03 12:10:47 +08:00
-----------
2018-12-20 04:02:45 +08: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-17 05:08:41 +08:00
2020-03-21 04:10:46 +08:00
If your command does not need access to stdin, consider using :ref: `source <cmd-source>` instead.
2018-12-17 05:08:41 +08:00
2019-11-18 23:02:21 +08: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-17 05:08:41 +08:00
2019-04-26 21:30:13 +08:00
Example
-------
2018-12-19 11:14:04 +08:00
2019-04-26 21:30:13 +08:00
The following code will call the ls command and truncate each filename to the first 12 characters.
2018-12-19 11:14:04 +08:00
::
2019-04-26 21:30:13 +08:00
set cmd ls \| cut -c 1-12
2018-12-19 11:14:04 +08:00
eval $cmd
2018-12-17 05:08:41 +08:00