G
G
Gring762015-10-12 07:12:29
bash
Gring76, 2015-10-12 07:12:29

How to archive many folders and give them individual archive names?

Good day.
There is a folder with a bunch of directories.
like
/home/user1/
/home/user1/dir1
/home/user1/dir2
/home/user1/dir3
/home/user1/dir4
/home/user1/dir5
..
/home/user1/dir500
Each dir* folder has its own a bunch of files.
How to optimally make SEPARATE archives of dir* folders and delete everything that is in these folders.
Those. the output would be
/home/user1/dir1.tar.gz
/home/user1/dir2.tar.gz
/home/user1/dir3.tar.gz
/home/user1/dir4.tar.gz
/home/user1/dir5 .tar.gz
..
/home/user1/dir500.tar.gz

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Saboteur, 2015-10-12
@Gring76

find /home/user1/ -type d -maxdepth 1 -name "dir*" -exec tar cvfz {}; rm -rf {} \;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question