I have an input file InputFile.csv that contains 2 types of rows. One type is a file name and the second is information: File1.txt, Row12,Y row23,N File2.txt, Row1,Y Row19,Y The first type is the name of a file that already exists and the second are rows that should be removed or not removed based on the Y or N. What this script needs to do is read the input file and create separate files and put the rows for a given file into these new files. These can then be passed to other utilities for other work. Code: while read LINE do IFS="," set -A array ${LINE} SEG_ONE=${array[0]} SEG_TWO=${array[1]} if [[ ${SEG_ONE} == File* ]] then RM_FILE=${SEG_ONE}.remove else if [[ ${SEG_TWO} == "Y" ]] then echo ${SEG_ONE} >> ${RM_FILE} fi fi done < InputFile.csv for WORK_FILE in `ls *.remove` do echo [${WORK_FILE}] done I would expect my output to be: [File1.txt.remove] [File2.txt.remove] Instead I am getting: [File1.txt.remove File2.txt.remove] So the ls sees it as one file name. Can anyone explain why and what I can change to make the expected output happen?
hi, the problem comes from the IFS, you should restore it. to avoid this, you could set IFS "locally" for `read' (I've removed useless array): Code: while IFS=',' read SEG_ONE SEG_TWO do ... done < file2read also, you should tell what shell you're using, it seems it's KSH, that I'm not used to. and, `ls' is useless inside scripts, for example: Code: printf '[%s]\n' *.remove simply does the job.