skip to content
Alvin Lucillo

Command substitution

/ 1 min read

You can run a command and use its output inside a string. In the example below, pwd and date commands are used to print some information.

echo "Current directory: $(pwd)"
Current directory: /home/user

echo "Date today: $(date)"
Date today: Tue Oct 21 20:51:39 CST 2025