[TriLUG] bash spaces in filenames

Brent Verner brent at rcfile.org
Thu May 4 17:30:04 EDT 2006


[2006-05-04 12:58] James Tuttle said:
| I'm need to grab a few hundred songs out of a few thousand to dump to my
| wife's IPod.  I have a list of the files she selected and I wrote a
| little bash script to grab them and sync them to her IPod, but it fails
| on spaces in filenames.  Probably on things like ' and & and - also.
| Any ideas?


FILES="Barry White - Let's Get It On.mp3
Barry White - Shaft Theme.mp3"

# This could just as easily be the output of ls...
#   ls somedir | while read file;
echo "$FILES" | while read file;
do
  if [ -e "$file" ]; then
    echo "\"$file\" exists"
  else
    echo "\"$file\" doesn't exist"
  fi
done


hth.
  b



More information about the TriLUG mailing list