Personal tools
You are here: Home Unix Network and Scripts clone directories
Document Actions

clone directories

by admin last modified 2008-06-14 21:54

Sometimes, you have to copy a directory structure from one computer to an other. A small script may help you.

#!/bin/sh

# get the list with
# find /opt/mytree/data -name "*" -type d -exec ls -ld {} \;
# copy the list you your target machine
# you may use scp
DATEIEN=`cat /var/tmp/fileliste `

cat /var/tmp/fileliste | while read line ; do

        BESITZER=`echo $line | awk '{ print $3 }'`
        GRUPPE=`echo $line | awk '{ print $4 }'`
        VERZEICHNIS=`echo $line | awk '{ print $9 }'`

        u=`echo $line | cut -b 2-4`
        g=`echo $line | cut -b 5-7`
        o=`echo $line | cut -b 8-11`

        mkdir -p $VERZEICHNIS
        chown $BESITZER:$GRUPPE $VERZEICHNIS
        chmod u=$u $VERZEICHNIS
        chmod g=$g $VERZEICHNIS
        chmod o=$o $VERZEICHNIS
done


Powered by Plone CMS, the Open Source Content Management System

This site conforms to the following standards: