Show 4 more comments. If the source files are sparse or have large sequences of NUL characters, you could make a sparse output file saving time and disk space with on GNU systems : find. StephaneChazelas - thanks a lot, your help and knowledge is deeply appreciated! I'm not convinced that there will be many cases where fallocate will negate the overhead of the extra find , even though it will be faster the second time round. Show 6 more comments. 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 1. Hot Network Questions.
Find centralized, trusted content and collaborate around the technologies you use most. Connect and share knowledge within a single location that is structured and easy to search. Is there a way to concatenate or gzipping these files into one gzip file without having to decompress them? In practice we will use this in a web database CGI.
Where the web will receive a query from user and list out all the files based on the query and present them in a batch file back to the user.
Per the gzip RFC ,. A gzip file consists of a series of "members" compressed data sets. Note that this is not exactly the same as building a single gzip file of the concatenated data; among other things, all of the original filenames are preserved. However, gunzip seems to handle it as equivalent to a concatenation. Since existing tools generally ignore the filename headers for the additional members, it's not easily possible to extract individual files from the result.
If you want this to be possible, build a ZIP file instead. Since the metadata is uncompressed, it's simple enough to strip off the gzip headers and tack on ZIP file headers and a central directory record instead.
Refer to the gzip format specification and the ZIP format specification. Multiple compressed files can be concatenated. In this case, gunzip will extract all members at once. For example:. So to get all members individually, you will have to use something additional or write, if you wish to do so. If you wish to create a single archive file with multiple members so that members can later be extracted independently, use an archiver such as tar or zip.
GNU tar supports the -z option to invoke gzip transparently. I tried the other answer of 'gz -c' but I ended up with garbage when using already gzipped files as input I guess it double compressed them. How are we doing? Please help us improve Stack Overflow. Take our short survey. Stack Overflow for Teams — Collaborate and share knowledge with a private group.
Create a free Team What is Teams? Collectives on Stack Overflow. In Linux, we are having the functionality to create the single concatenate file from the multiple files. We can use the sort command to make the single concatenated file. In the File Concatenation, we having the functionality to use the different control statements like while, for, etc. As per the requirement, we can use any type of looping mechanism. In the above command, we are using the for control statement.
We are passing the list of files to be concatenate. As per the requirement, we can merge or concatenate the single file form the multiple files. It will help to analyze the data into a single file rather than referring to the multiple files. This is a guide to Linux Concatenate Files. Here we discuss the introduction, how to Linux Concatenate Files work?
You may also have a look at the following articles to learn more —. Submit Next Question. By signing up, you agree to our Terms of Use and Privacy Policy. Forgot Password? This website or its third-party tools use cookies, which are necessary to its functioning and required to achieve the purposes illustrated in the cookie policy.
0コメント