标签:director pcre tar pac .gz 3.2 目录文件 -- pfile
1. 目的[root@reedoracle BakDir]# find /root -size +1M |xargs ls -lh
-rw-r--r-- 1 root root 4.7M Jan 17 2017 /root/ansible-packages/ansible-2.2.1.0-1.el6.noarch.rpm
-rw-r--r-- 1 root root 1.5M Jul 3 2011 /root/ansible-packages/python-babel-0.9.4-5.1.el6.noarch.rpm
-rw-r--r-- 1 root root 7.5M Feb 3 2017 /root/ansible-packages.tar.gz
-rw------- 1 root root 6.3M Mar 14 2017 /root/.cache/pip/http/6/b/5/7/b/6b57b626d79b36c0d0749210d43211130a56666ce3959ca91a518127
-rw-r--r-- 1 root root 13M Feb 6 13:54 /root/dir1/dir2/file2
-rw-r--r-- 1 root root 15M Feb 6 13:55 /root/dir1/dir3/file3
-rw-r--r-- 1 root root 23M Feb 6 13:54 /root/dir1/file1-1
-rwxr-xr-x 1 root root 3.7M Nov 18 03:31 /root/nginx-1.12.2/objs/nginx
-rw-r--r-- 1 root root 2.0M Nov 18 02:53 /root/pcre-8.40.tar.gz
-rw-r--r-- 1 root root 1.2M Mar 8 2017 /root/PI.DAT
复制后的路径文件:
[root@reedoracle BakDir]# find /tmp/BakDir -size +1M |xargs ls -lh
-rw-r--r-- 1 root root 4.7M Feb 12 12:19 /tmp/BakDir/root/ansible-packages/ansible-2.2.1.0-1.el6.noarch.rpm
-rw-r--r-- 1 root root 1.5M Feb 12 12:19 /tmp/BakDir/root/ansible-packages/python-babel-0.9.4-5.1.el6.noarch.rpm
-rw-r--r-- 1 root root 7.5M Feb 12 12:19 /tmp/BakDir/root/ansible-packages.tar.gz
-rw------- 1 root root 6.3M Feb 12 12:19 /tmp/BakDir/root/.cache/pip/http/6/b/5/7/b/6b57b626d79b36c0d0749210d43211130a56666ce3959ca91a518127
-rw-r--r-- 1 root root 13M Feb 12 12:19 /tmp/BakDir/root/dir1/dir2/file2
-rw-r--r-- 1 root root 15M Feb 12 12:19 /tmp/BakDir/root/dir1/dir3/file3
-rw-r--r-- 1 root root 23M Feb 12 12:19 /tmp/BakDir/root/dir1/file1-1
-rwxr-xr-x 1 root root 3.7M Feb 12 12:19 /tmp/BakDir/root/nginx-1.12.2/objs/nginx
-rw-r--r-- 1 root root 2.0M Feb 12 12:19 /tmp/BakDir/root/pcre-8.40.tar.gz
-rw-r--r-- 1 root root 1.2M Feb 12 12:19 /tmp/BakDir/root/PI.DAT
4.3具体实现
[root@reedoracle ~]# cat CpFiles.sh
#!/bin/bash
#Func:cp files include directory
#Author:reed
. /etc/profile
SourcePath="/root"
DestPath="/tmp/BakDir"
#mkdir backup directory
[ ! -d $DestPath ] && mkdir -p $DestPath
Func_CpFiles()
{
for FileList in $(find $SourcePath -size +1M);do
#mkdir
[ ! -d ${DestPath}$(dirname $FileList) ] && mkdir -p ${DestPath}$(dirname $FileList)
#copy
cp -rf $FileList ${DestPath}$(dirname $FileList)
done
}
Func_CpFiles
标签:director pcre tar pac .gz 3.2 目录文件 -- pfile
原文地址:http://blog.51cto.com/luweikai/2071447