#!/bin/bash for n in * do x=${n//\ /\_} if [ -f "$n" ] then mv -iv "${n}" "${x}" fi done