I have a number of files in a folder, and I want to replace every space character in all file names with underscores. How can I achieve this?
Quote your variables:
for file in *; do echo mv "'$file'" "${file// /_}"; done
Remove the "echo" to do the actual rename.