全部博文(28)
分类: LINUX
2007-09-13 17:11:04
$ touch -t 09131630 /tmp/timestamp $ find /your/project -name '*.[ch]' -newer /tmp/timestamp $ rm -f /tmp/timestamp |
#!/bin/bash if [ $# -lt 2 ] ; then echo "cp_newer_files src_dir date [dst_dir]" echo " src_dir: the directory you copy files from" echo " date : which date the files are newer than " echo " dst_dir: the directory you copy files to, default: /tmp/myproject" exit 1 fi src_dir=$1 stamp_date=$2 if [ $# -eq 3 ] ; then dst_dir=$3 else dst_dir=/tmp/myproject fi stamp_file=/tmp/stamp_date$$ touch -t $stamp_date $stamp_file if [ $? -ne 0 ] ; then echo "bad stamp date!!" exit 1 fi find_files=`find $src_dir -name '*.[ch]' -newer $stamp_file` i="0" for cfile in $find_files ; do dst_file=$dst_dir${cfile#$src_dir} mkdir -p `dirname $dst_file` cp -a $cfile $dst_file i=$[$i+1] echo "" echo "copy $cfile" echo "===> $dst_file" done echo ""
echo "<=== $i files copied. " rm -f $stamp_file |
$ find /your/project -name '*.[ch]' -newer /tmp/timestamp | xargs cp -a --target-directory=/tmp/myproject --parents |
$ find /your/project -name '*.[ch]' -newer /tmp/timestamp -print0 | xargs -0 cp -a --target-directory=/tmp/myproject --parents |