Browse Source

增加tar脚本

liuyuqi-dellpc 5 years ago
parent
commit
922d9e38d8
2 changed files with 52 additions and 0 deletions
  1. 30 0
      shell/tar.py
  2. 22 0
      shell/tar.sh

+ 30 - 0
shell/tar.py

@@ -0,0 +1,30 @@
+#!/usr/bin/env python
+# -*- encoding: utf-8 -*-
+'''
+@Author  :   liuyuqi
+@Contact :   liuyuqi.gov@msn.cn
+@Time    :   2019/11/11 20:18:09
+@Version :   1.0
+@License :   (C)Copyright 2019
+@Desc    :   200个文件夹打包一次
+'''
+
+import os
+
+rootPath = r"/home/twtech/github/python/crawl-mrdx/data"
+size = 3
+count = 1
+count2 = 1
+currentDir=""
+
+for path in os.listdir(rootPath):
+    if os.path.isdir(os.path.join(rootPath,path)):
+        currentDir = currentDir + " " + path
+        if count % size == 0:
+            shellStr = "tar -zcf /ossfs/crawl-mrdx/mrdx%s.tar.gz" % (
+                count2) + currentDir
+            os.system(shellStr)
+            # print(shellStr)
+            currentDir=""
+            count2 = count2 + 1
+        count = count + 1

+ 22 - 0
shell/tar.sh

@@ -0,0 +1,22 @@
+#!/bin/sh
+
+# 已经用python实现,暂不用
+cd /home/twtech/github/python/crawl-mrdx/data
+
+list_alldir(){  
+    for file in `ls -a $1`  
+    do  
+        if [ x"$file" != x"." -a x"$file" != x".." ];then  
+            if [ -d "$1/$file" ];then  
+                echo "$1/$file"  
+                list_alldir "$1/$file"  
+            fi  
+        fi  
+    done  
+}  
+  
+list_alldir ./test  
+
+
+
+