I need to get around the requirement of --exclude=* to have all the parent directories of the files and directories that are to be included. So given the file.. /startdirectory/subdirectory1/subdirectory2/filetobecopied I need to include / /subdirectory1 /subdirectory1/subdirectory2 I could just include the entire directory structure , but alternatively just include the needed paths. So the question is how can I extract every parent directory of this path? I tried writing a recursive routine that accepts /startdirectory as $1 and the pathname of filetobecopied as $2. Here is latest incarnation, which doesn't work right, of course. #!/bin/sh rootpath="$1" subpath="$2" if [ $rootpath -ef $subpath ] then echo "end of recursion" echo $subpath else echo $subpath SUBDIRECTORY=$(/usr/bin/dirname $subpath) echo $SUBDIRECTORY /root/scripts/subdirname $SUBDIRECTORY fi -- Maurice Volaski, mvolaski@aecom.yu.edu Computing Support, Rose F. Kennedy Center Albert Einstein College of Medicine of Yeshiva University
Maurice Volaski wrote:> I need to get around the requirement of --exclude=* to have all the > parent directories of the files and directories that are to be > included. So given the file.. > > /startdirectory/subdirectory1/subdirectory2/filetobecopied > > I need to include > / > /subdirectory1 > /subdirectory1/subdirectory2Maybe --include=*/ --exclude=* ? Of course, that will sync the entire directory tree, but without files that are not explicitely included. Ugly, but won't waste much transfer time. To the list in general: Wasn't there a --files-from option someone was working on? Max.
>Maybe --include=*/ --exclude=* ? > >Of course, that will sync the entire directory tree, but without >files that are >not explicitely included. >Ugly, but won't waste much transfer time.Seems I have a working script now... #!/bin/sh # name of script: subdirname # This script takes a root directory and subdirectory and # returns the intervening parent directories # needed to include files in the given subdirectory # when exclude=* is passed to rsync. # paths must be enclosed in double quotes in case they # contain spaces. ROOTPATH="$1" SUBPATH="$2" if [ "$ROOTPATH" != "$SUBPATH" ] then SUBDIRECTORY=`/usr/bin/dirname "$SUBPATH"` /bin/echo "$SUBDIRECTORY" /usr/local/bin/subdirname "$ROOTPATH" "$SUBDIRECTORY" fi -- Maurice Volaski, mvolaski@aecom.yu.edu Computing Support, Rose F. Kennedy Center Albert Einstein College of Medicine of Yeshiva University