PFranchise
PFranchise

Reputation: 6762

script to tar and copy directories

Hey, I think 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?

Upvotes: 0

Views: 708

Answers (1)

icyrock.com
icyrock.com

Reputation: 28628

Use find -maxdepth 2 to restrict the depth.

Upvotes: 1

Related Questions