Quantcast
Channel: Compressing multiple files in different folders without folder structure - Unix & Linux Stack Exchange
Viewing all articles
Browse latest Browse all 3

Answer by Kannan Mohan for Compressing multiple files in different folders without folder structure

$
0
0

Adding to @Marks answer

We can do it with the help of -T and --transform switches of tar command.

I have the directory structure as below.

|-- foo1|   |-- file1.txt|   |-- file2.txt|   `-- file3.txt|-- foo2|   |-- file4.txt|   |-- file5.txt|   `-- file6.txt|-- foo3|   |-- file7.txt|   |-- file8.txt|   `-- file9.txt`-- foo4    |-- file10.txt    |-- file11.txt    `-- file12.txt

We can tar the files with directory name included

$ find -type f | tar --transform="s,/,-,2" -czvf compress.tgz -T -

And without directory name included.

$ find -type f | tar --transform="s,.*/,," -czvf compress.tgz -T -

Viewing all articles
Browse latest Browse all 3

Trending Articles