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