Roland Turner

about | contact

Bash parameter expansion magic for “substitute all”

The relevant bit is:

for n in *; do mv “$n” ${n// /_}; done

Noting that the double / after the variable name is what tells it to substitute all (rather than first-only).