perform string substitution for command