开发者

script to tar and copy directories

开发者 https://www.devze.com 2023-01-28 14:09 出处:网络
Hey, I thin开发者_开发知识库k the best way to ask this question is to show what I need to happen.

Hey, I thin开发者_开发知识库k the best way to ask this question is to show what I need to happen.

I need to go from:

Project_Direcory
   Project
      Solution1
      Solution2
      Solution3

To:

Project_Direcory
   Project.tar.gz
   Solution1.tar.gz
   Solution2.tar.gz
   Solution3.tar.gz

Project.tar.gz still contains all the Solution directories. I am having issues where it is copying files that are inside of the solution directories and placing them in the Project_Directory. There are also some text files in Project, that should not be copied. I am currently trying:

for file in $(find /place/* -type d);do tar zcf  ${file}.tar.gz $file;done
for file in $(find /place/* );do mv  ${file} /place;done
for file in $(find /place/* -type d);do cp -r  ${file} /place;done

What is the best way to do this?


Use find -maxdepth 2 to restrict the depth.

0

精彩评论

暂无评论...
验证码 换一张
取 消