ibi0tux
ibi0tux

Reputation: 2629

How to add files to zip archive without a intermediate folder

I'm using zip program in a bash script and i would like to create an archive containing all files in a folder without adding the folder itself to the archive.

I have such files :

script.sh
files/
files/1
files/2

I'm using this command in script.sh

zip -q -9 -r arch.zip files/*

but this creates a files folder in the archive and i would like to get files 1 and 2 directly at the root of the archive.

How can i modify the parameters passed to zip command to prevent it from adding files in this archive ?

Thanks

FIXED :

Here and Here

Obviously, SO search engine is more efficient when the question is posted than before ...

Upvotes: 5

Views: 13777

Answers (2)

user4619227
user4619227

Reputation: 51

you should use -j key. Try this way:

zip -q -9 -j arch.zip files/*

Upvotes: 5

Ansgar Wiechers
Ansgar Wiechers

Reputation: 200413

cd files
zip -q -9 -r ../arch.zip *

Upvotes: 5

Related Questions