Okay, here is the question.
How do I parse a file with 'codes' in them, and based on file names in a directory, if the file name also has the same code, move that file to another directory.
The files name would be 02gr_text_CODE123_stuff.dat. There may be more than one file in this directory, so also another file by the name of 05_gr_text_CODE987 or 76gr_new_CODE456_morestuff.dat. The codes in the file would be CODE123 and CODE456.
Here is what I have come up with as a starting point...
val_file=/directory/err_campcd
while read -r line
do
for file in *
do
cd /codedirectory
code1=`ls | grep gr_text | cut -b3- | sed -e 's/gr_text_//g' | cut -c1-7`
code2=`ls | grep gr_new | cut -b3- | sed -e 's/gr_new_//g' | cut -c1-7`
if ${code1} -eq ${line}
then
echo "moving code1 rejected files"
elseif ${code2} -eq ${line}
echo "moving code2 rejected files"
else
echo "no rejected files"
fi
done
done < $val_file