I want to check if all thes files exists in the directory
the keywords are acc.csv, faf.csv, prom.csv, subs.csv
apart from this all the other things vary time to time (like the field seperator used in the file (can be.,-,_ etc) and the names OTP UFSC will vary.
2) if the file does not exist I have to touch (Create a empty file by that name)
Example : Imagine the file OTP_UFSC_20120530000000_acc.csv doesnot exist
in the directory
I have to search first if a file *acc.csv exist in the directory or not. If not i will extract the prefix anything before acc.csv (in this case OTP_UFSC_20120530000000_) from an existing file which is common to all the files in the directory
and create a file OTP_UFSC_20120530000000_acc.csv
Hi Thanks for your quickest reply.
Also the no of letters before the acc.csv varies and it also can have any field seperators like (- . _) etc
Please can you help me.
---------- Post updated at 09:27 PM ---------- Previous update was at 09:24 PM ----------
This is my code and its not working
please provide me a suggestion
if [ "$VERSION" = "1.1" ]
then
set "subscriber" "promplan" "mapping" "dedicatedaccount" "faflistSub" "faflistAcc" "accumulator" "pam_account";
for i in 1 2 3 4 5 6 7 8;
do
count=`ls /mnt/sf_MY_LAPTOP/SDPDUMP/*.csv|grep -i _\.csv$|wc -l`;
if [ $count -eq 0 ]
then
touch <file_prefix>_$1.csv;
shift
elif
exit;
done
fi
done
So your only way to find the prefix is to extract the longest common starting substring among all the names of files in the directory, isn't it?
--
Bye