Copy files to other location by KSH on aix

January 7, 2011 at 13:07:36
Specs: Windows XP
hi everyone

i have some concenrs who to copy some files with script ksh

source structure and it will be create more files with the consecutive and inside have xml files

/home/NKM00001/file0001.xml
/home/NKM00002/file0002.xml
/home/NKM00003/file0003.xml

i need copy the xml files to one folder , only xml files not with folders like this

/home/data/file0001.xml
/home/data/file0002.xml
/home/data/file0003.xml

every new xml file in the source folder need to be copied to destination folder , no copy all files, only the new files (no replace only new files from the last copy)
the script need to be schedule every hour via cron


thanks for yu help


See More: Copy files to other location by KSH on aix

Report •

#1
January 7, 2011 at 17:57:48
I will get you started. This script searches the basedir for all *.xml files and copies to the sourcedir:

#!/bin/ksh

basedir="/home"
sourcedir="/home/nails/data"

find "$basedir" -follow -type f -name "*.xml" -print|while read file
do
   myfile=$(basename "$file")
   cp "$file" "$sourcedir/$myfile"
done

# end script

Sorry, but I don't understand this requirement:

(no replace only new files from the last copy)

If you plan on running this from cron, perhaps find's -newer option can help you. Check out this link:

http://www.computing.net/answers/so...


Report •

#2
January 7, 2011 at 20:13:14
every day new files are created only need copy the last new files 6 hours a go the cron need to be schedule every 6 hours after some weeks the fs maybe is too big its no necesary copy the files from 4 weeks ago only the new from the last run

regards


Report •
Related Solutions


Ask Question