[Bash] Evaluate a string as a shell command

Created on November 30, 2026

The eval builtin joins its arguments and evaluates the result as shell code. This example builds and runs ls -la from two variables containing fixed strings.

#! /bin/bash

command="ls"
option="-la"

eval $command $option

Use only trusted text with eval.

Bash Shell command