I've got a Bash script that was working fine until I changed the input file; basically what the script does is parse a text file then run some commands on each line of the file. The problem started when I added a line (to the input file) which contains spaces. >Here's the skeleton of the code:
for FILENAME in `cat $SRCFILE` do ls $FILENAME (some other stuff) done
Trouble is, I' m sure cat is breaking up the source file because the ls fails when it looks for a file with the wrong name, e.g. SRCFILE contains "file 1" then I get two errors from ls, one for "file" and one for "1".
[Yes, the problem would go away if I just renamed the files to exclude spaces, but the filenames are out of my control so that's not an option.]
I thought there used to be a way to quote/requote a string to avoid this fragmentation. (I'm thinking back ~15 years to when I used to churn out scripts on AIX, HP-UX, SunOS, etc.)
My other thought is to change to loop to check for EOF and then read each line in turn, but I have a nasty feeling I may just hit the same problem.
/Obviously too early and/or insufficient coffee to be solving this one!