Because your answer was more correct, and you've inexplicably taken it down, I've changed my answer to be what yours was. Just note that "not promoting" does not necessarily mean actively downvoting. I would have altered my answer or taken it down after your comment alone. If anyone would like to use a regex with to locate specific files in a subdirectory to zip, I'd recommend using find. Ben Trono Ben Trono 30 6 6 bronze badges. 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. Stack Gives Back Safety in numbers: crowdsourcing data on nefarious IP addresses.
Featured on Meta. New post summary designs on greatest hits now, everywhere else eventually. Linked This post describes how to gzip each file individually within a directory structure. However, I need to do something slightly different. I need to produce one big gzip file for all files under a certain directory.
I also need to be able to specify the output filename for the compressed file e. Edit: After review and comments I realized that people may get confused with compressFileName without an extension. If you want you can use.
Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. How to gzip all files in all sub-directories into one compressed file in bash Ask Question. Asked 9 years, 4 months ago. What can you do now? How to gzip compress a file in Linux? Instead of trying to compress the folder directly, you should use tar on it first. The tar command will collate all the files into one archive file.
If you combine tar with gzip, the tar command will create one single archive file from the folder and then gzip will compress this archive file. The good thing is that you can do both of these steps in one single command by using the z option. The command looks something like this:. The resulting archive can then be extracted with tar -zxvf or even zcat file. Point being that the tar is completely independent from the gzip, the tar command just includes gzip support for convenience.
Does the naming of the archive affect anything machine-wise? I know it would be nice to let people know the algorithm originally used to zip it hence. Add a comment. Stephen P 1 1 silver badge 7 7 bronze badges. JeffSchaller: This is an answer. It is sad most people don't wish to think as far. I'm upvoting this answer since I think the product a zip file is likely more important than the method using gzip. I scripted these 2 commands: gzipdir :!
Nothing done. Archemar To zip up ALL the files in a directory: find. I use it a lot too and pixz , but does it work when pipes and output redirection come into play? Jeff Jeff 21 1 1 bronze badge. Sign up or log in Sign up using Google.
0コメント