Debugging Scripts
Variable Probe
Split a Debug Value
A probe line prints the values a script is about to use. Parameter expansion can split a compact debug value into named parts.
Program
Play the script to choose a probe value and see the parsed fields.
variable_probe.sh
#!/usr/bin/env bash
probe=
name="${probe%%:*}"
count="${probe##*:}"
echo "probe:$name=$count"
#!/usr/bin/env bash
probe=
name="${probe%%:*}"
count="${probe##*:}"
echo "probe:$name=$count"
probe
A probe is a temporary diagnostic line that exposes values during development.
prefix trim
`${probe%%:*}` keeps the text before the first colon-shaped separator.
suffix trim
`${probe##*:}` keeps the text after the last colon-shaped separator.