Hi,
kann auch kein Perl aber mit der bash + utils geht das auch.
Nennen wir folgendes Skript cp_equal.sh
Code:
#!/bin/bash
FILE=/home/jgbauman/unsorted/trash/test/home/$1
BACKUP=/home/jgbauman/unsorted/trash/test/home1/$1
if test ! -e $BACKUP; then
echo $BACKUP doesn´t exist
exit
fi
if test ! -e $FILE; then
echo $FILE doesn´t exist
exit
fi
# not newer ...
if test ! $FILE -nt $BACKUP ; then
# ... and not older ...
if test ! $FILE -ot $BACKUP ; then
# ... means the same time
# get sizes
S1=`wc -l $FILE | cut -f1 -d" " `
S2=`wc -l $BACKUP | cut -f1 -d" "`
# test, don´t know if neccessary
if test ! $S1 = $S2; then
# these file perhaps need manual checking
echo same time, but differ in size: $BACKUP and $FILE;
#comment out following line if you want to copy them regardlessly
exit
fi
#equal size
#echo the action
echo copying $BACKUP to $FILE
ls -l $BACKUP
ls -l $FILE
echo
#uncommet this for the real action
#cp -a $BACKUP $FILE
fi
fi
Liegt es im Pfad und ist ausfuehrbar, dann kannst Du es mit
Code:
cd /home1
find . -type f -exec cp_equal.sh \{\} \;
auf alle Dateien unter /home1 loslassen.
Der eigentliche cp Befehl ist erst mal auskommentiert, damit die testen kannst ob's auch das ist was Du willst.
Auch werden Dateien mit gleichen Datum, aber unterschiedlicher Laenge gesondert behandelt.
Also erst mal testweise Laufen lassen und dann entscheiden ob es das ist was du brauchst.
Lesezeichen