[TriLUG] bash spaces in filenames

James Tuttle jim_tuttle at ncsu.edu
Thu May 4 12:58:36 EDT 2006


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?


#/bin/env bash

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

for file in $FILES
  do
    if [ -e $file ]; then
      FILE_LIST="$file $FILE_LIST"
    else
      echo "$file doesn't exist"
    fi
  done

snip

Thanks,
Jim



More information about the TriLUG mailing list