Add a comment. Active Oldest Votes. Use the -j or --junk-paths option in your zip command. From the zip man page : -j --junk-paths Store just the name of a saved file junk the path , and do not store directory names. By default, zip will store the full path relative to the current directory. Improve this answer. This appears to be the correct answer. This will omit all folders in the archive, and if you have duplicate file names in different folders, this will blow up.
This has its place, but only if you don't care about folders and just want files. Not what the OP was asking for, but still good knowledge — Govind Rai. Or if running it from outside the folder you could run, zip -r test. Ok I ran the script and it created a the parent directory in the archive i want only the contents of the folder to be in the archive — Dami.
Show 7 more comments. How about this command? While this is a correct answer, the introduction doesn't sound like you're convinced yourself. It would also help to explain a little bit, what the command does. This was my solution too, but I dislike it because it involves cd. Was hoping there was a way to specify the stored path more precisely. Only thing what worked for me, — progonkpa. Hope this helps. Kenneth Kenneth 3 3 silver badges 3 3 bronze badges. I wanted to add this as a comment to Alfred UC 's answer but I don't have enough reputation for that.
If it actually solves the problem, then it may be a solution. AndrewD AndrewD 4, 2 2 gold badges 27 27 silver badges 30 30 bronze badges. Qader Dorosti Qader Dorosti 31 1 1 bronze badge. If a directory becomes empty after removal of the files, the directory is also removed.
No deletions are done until zip has created the archive without error. This is useful for conserving disk space, but is potentially dangerous so it is recommended to use it in combination with -T to test the archive before removing all input files. Sign up or log in Sign up using Google.
Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Email Required, but never shown. The Overflow Blog. Podcast Making Agile work for data science. Stack Gives Back Featured on Meta. New post summary designs on greatest hits now, everywhere else eventually.
Linked Related Hot Network Questions. Question feed. Stack Overflow works best with JavaScript enabled. Add a comment. Active Oldest Votes. Improve this answer. From man zip : -b path --temp-path path Use the specified path for the temporary zip archive.
Community Bot 1. From man zip : -b path Use the specified path for the temporary zip archive. Chris Down Chris Down k 22 22 gold badges silver badges bronze badges. Raza Raza 3, 5 5 gold badges 27 27 silver badges 31 31 bronze badges. Dmitrii Cretu Dmitrii Cretu 21 1 1 bronze badge. How is this better? Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Email Required, but never shown.
0コメント