I am trying to loop inside a directory and rename the file name with space. But i m getting the bad substitution error while running it with sh test.sh
#!/bin/bash
for f in /home/admin1/abc/*.kmz
do
mv "$f" "${f// /_}"
#rm $i
done
Since i need to configure in crontab i may need to run it with sh command not with ./
bash test.sh.