Results 1 to 1 of 1
Hi,
I have a set of files in one folder. The file names are of the format ODS.POS.<TABLENAME>.<DATE>.dat
I need to copy all the files from the current directory to ...
- 09-13-2010 #1Just Joined!
- Join Date
- Jul 2010
- Posts
- 16
Issue in find and cp in script
Hi,
I have a set of files in one folder. The file names are of the format ODS.POS.<TABLENAME>.<DATE>.dat
I need to copy all the files from the current directory to /posouttemp directory when the filename matches any of the table names in a flat file.
I have the below script. However since there is a * mentioned in search it copies all the files even if the tablename is not exact match.
while read line
do
find . -name *$line* -exec cp '{}' ../posouttemp/ \;
done <common_files
sample table names in the file
------------------
AS_ITM
AS_ITM_I8
CA_CLD
CA_CLD_LV
CA_CLD_PRD
CA_DY_BSN
CA_PRD_RP
CA_PRD_RP_TM
CA_PRD_RP_V4
CD_GEO
Issue :- This copies all files in the directory with table names like AS_ITM_UNK, CA_CLD_LV_18 even though it is not exact match. how do I modify the code to search the exact match for the third field in the file name?
Can somebody help here?
Thanks
Maya


Reply With Quote