Question: I have a directory called /HOLD on my RHEL4 Linux server. Files get dumped into that directory that need to be moved into another directory based on the file name. The file names are as follows:
BBB-00019-615619-65465183.pdf
QLD-00123-698231-651321684321.pdf
COW-00102-321583-48731.pdf
Where the first set of digits (between the first and second dashes) is the "customer number". So in the first BBB example, 00019 is the customer number.
I need a scrip that reads the /HOLD directory, finds the customer number (which will always be the 5th through 9th characters) and move it to the /CUSTOMER/CUSTNUM directory.
So for the first BBB example, the file would be moved to /CUSTOMER/00019 directory.
Here is the catch. I need the script to first check to see if the customer directory exists, and if it doesnt, it needs to CREATE the directory, THEN move the file into the the directory.