I have this filename containing 3 whitespaces that I extracted from an access database, it looks like this, single quotes included =>>> 'Test de map.csv' I am trying to replace spaces with underscore within a for loop, inside a .sh, unfortunately, it does not seem to be working with:
for file in `ls *.csv`; do
mv "$file" `echo "$file" | tr -s ' ' | tr ' ' '_'`
# mv "$file" `echo "$file" | sed -e "s/ /_/g" -e "s/[\[{\\']//g"`
# find . -name "* *" -type f | rename "s/ /_/g"
done
Whereas it works perfectly when I type directly this command :
mv 'Test de map.csv' `echo 'Test de map.csv' | tr -s ' ' | tr ' ' '_'`
Someone might help ?