Shell scripts often combine variables with external tools. This example models a grep command and its selected match so the replay stays deterministic.

Program

Play the script to choose the pattern and see the command text and matched log line.

grep_filter_plan.sh
#!/usr/bin/env bash

pattern=
command="grep '$pattern' app.log"
case "$pattern" in
    error) match="error db" ;;
    warn) match="warn cache" ;;
esac
echo "$command -> $match"
#!/usr/bin/env bash

pattern=
command="grep '$pattern' app.log"
case "$pattern" in
    error) match="error db" ;;
    warn) match="warn cache" ;;
esac
echo "$command -> $match"
tool command A script can build the command text from shell variables.
grep `grep` filters text by matching a pattern.
deterministic replay The lesson models the tool output so static replay is stable everywhere.