Bash script to process file without regard for case

Hello,

I have a Bash script that processes a text file so that the existing file will look something like this:

/www/repository/2010/201002231329532/LTLO_0407.pdf
/www/repository/2010/201002231329532/LTLO_0507.pdf
/www/repository/2010/201002231329532/LTLO_0607.pdf
/www/repository/2010/201002231329532/LTLO_0707.pdf
/www/repository/2010/201002231329532/LTLO_0807.pdf

Then the script uses a 'For-Do' loop to copy the files to another directory. Unfortunately, the original text file did not pay attention to case. So, when the copy takes place, some of the files are not recognized because of case and are not copied. Looking around for a solution, I did find the 'shopt -s nocasematch' and stuck it in my script, but it spits out errors.

Can someone give me an idea of how I might copy these files without regard for the case?

#!/bin/bash

cd /home/docs/wash_dig_arch

shopt -s nocasematch
sed 's/^\([0-9][0-9][0-9][0-9]\)/\/www\/repository\/\1\/\1/'g /home/docs/wash_dig_arch/serials_3_2010.txt > /home/docs/wash_dig_arch/Serials.txt

sleep 1
for x in `cat /home/docs/wash_dig_arch/Serials.txt`
do
cp $x /home/docs/wash_dig_arch/NEWDOCS/SERIALS
done
shopt -u nocasematch

The 'sed' line replaces the first 4 numbers on a line with '/www/repository/<first_4_num>/<first_4_num> and so has no dependency on case. The for loop copies each full path including the file name, which you have not changed, to the destination directory. I do not see how the case of the file is an issue unless the 'serials_3_2010.txt' file contains the wrong file name in the first place. If that is the case and you can not update the process that creates the file list then you can replace the 'cp' copy command and use the 'find' command to copy your files.

find . -iname "$x" -exec cp {} /home/docs/wash_dig_arch/NEWDOCS/SERIALS \;