First of all, I've read numerous post on here regarding this topic, but none have helped so far, e.g.
Zipping without creating parent folder Unix zipping sub directory not including parent directory
Here's what I want. I have the following folder structure:
- root
-- subroot
--- subsubroot
---- file1.foo
---- file2.foo
---- file3.foo
---- file4.foo
And the result of the zipped file should be, when unzipped
file1.foo
file2.foo
file3.foo
file4.foo
The crux is that the file*.foo
are just packages, thus basically being folders itself, so I tried using the -j
option in conjunction with my recursive option (-r
), but then I just get a flat hierarchy of all the files.
My current shell command looks like this:
find root/subroot/subsubroot -name '*.foo' | grep -v somestring | xargs -I % zip -r foos.zip %
However, the result of that will be exactly like the original structure with all the parent folder.
I don't necessarily have to use the zip
command, but the resulting file has to be a zip
.