Friday 16 December 2011

RSYNC files with a pattern from subdirectories to single directory

RSYNC files with a pattern from subdirectories to single directory

Hi all,
I have a situation where I need to RSYNC files from a directory which has different JSPs to a single directory. I am out of my options for a solution to this.

Explanation:
DIR1: /webdata/source
DIR2: /webdata/target

DIR1 has sub directories also like..
/webdata/source/dir1
/webdata/source/dir2
/webdata/source/dir1/dir3

each source directory has a JSP file and any file in the source may get deleted or new one gets created by my application.

I now want to RSYNC each file to target, but all in one place (one directory), which is in DIR2

I wrote below, but it leaves old files that are deleted in the source...

find $DIR1 -name "*.jsp" -exec cp -p {} $TEMP_DIR2 \;

rsync -pt --delete ${TEMP_DIR2} ${DIR2}

Thank you in advance..
Goli

No comments:

Post a Comment