Skip to main content
missing --s
Source Link
Stéphane Chazelas
  • 584.9k
  • 96
  • 1.1k
  • 1.7k

The xz documentation says

It is possible to concatenate .xz files as is. xz will decompress such files as if they were a single .xz file.

From my tests, this works even if the different files are compressed with different options; so in your case

cat -- *.log.xz > newfile.log.xz

will work fine.

To answer your more general question, you can pipe the output of a compound command, e.g.

for file in -- *.log.xz; do xzcat -- "$file"; done | xz -ve9 > newfile.log.xz

or any subshell. This would allow you to perform any processing you want to on your log files before recompressing them. However in the basic case this isn’t necessary either; you can decompress and recompress all your files by running

xzcat -- *.log.xz | xz -ve9 > newfile.log.xz

If you add -f this even works with uncompressed files, so

xzcat -f -- uncompressed.log *.log.xz | xz -ve9 > newfile.log.xz

would allow you to combine uncompressed and compressed logs.

The xz documentation says

It is possible to concatenate .xz files as is. xz will decompress such files as if they were a single .xz file.

From my tests, this works even if the different files are compressed with different options; so in your case

cat *.log.xz > newfile.log.xz

will work fine.

To answer your more general question, you can pipe the output of a compound command, e.g.

for file in *.log.xz; do xzcat "$file"; done | xz -ve9 > newfile.log.xz

or any subshell. This would allow you to perform any processing you want to on your log files before recompressing them. However in the basic case this isn’t necessary either; you can decompress and recompress all your files by running

xzcat *.log.xz | xz -ve9 > newfile.log.xz

If you add -f this even works with uncompressed files, so

xzcat -f uncompressed.log *.log.xz | xz -ve9 > newfile.log.xz

would allow you to combine uncompressed and compressed logs.

The xz documentation says

It is possible to concatenate .xz files as is. xz will decompress such files as if they were a single .xz file.

From my tests, this works even if the different files are compressed with different options; so in your case

cat -- *.log.xz > newfile.log.xz

will work fine.

To answer your more general question, you can pipe the output of a compound command, e.g.

for file in -- *.log.xz; do xzcat -- "$file"; done | xz -ve9 > newfile.log.xz

or any subshell. This would allow you to perform any processing you want to on your log files before recompressing them. However in the basic case this isn’t necessary either; you can decompress and recompress all your files by running

xzcat -- *.log.xz | xz -ve9 > newfile.log.xz

If you add -f this even works with uncompressed files, so

xzcat -f -- uncompressed.log *.log.xz | xz -ve9 > newfile.log.xz

would allow you to combine uncompressed and compressed logs.

Add xzcat -f variant.
Source Link
Stephen Kitt
  • 481.4k
  • 60
  • 1.2k
  • 1.4k

The xz documentation says

It is possible to concatenate .xz files as is. xz will decompress such files as if they were a single .xz file.

From my tests, this works even if the different files are compressed with different options; so in your case

cat *.log.xz > newfile.log.xz

will work fine.

To answer your more general question, you can pipe the output of a compound command, e.g.

for file in *.log.xz; do xzcat "$file"; done | xz -ve9 > newfile.log.xz

or any subshell. This would allow you to perform any processing you want to on your log files before recompressing them. However in thisthe basic case this isn’t necessary either; you can decompress and recompress all your files by running

xzcat *.log.xz | xz -ve9 > newfile.log.xz

If you add -f this even works with uncompressed files, so

xzcat -f uncompressed.log *.log.xz | xz -ve9 > newfile.log.xz

would allow you to combine uncompressed and compressed logs.

The xz documentation says

It is possible to concatenate .xz files as is. xz will decompress such files as if they were a single .xz file.

From my tests, this works even if the different files are compressed with different options; so in your case

cat *.log.xz > newfile.log.xz

will work fine.

To answer your more general question, you can pipe the output of a compound command, e.g.

for file in *.log.xz; do xzcat "$file"; done | xz -ve9 > newfile.log.xz

or any subshell. However in this case this isn’t necessary either; you can decompress and recompress all your files by running

xzcat *.log.xz | xz -ve9 > newfile.log.xz

The xz documentation says

It is possible to concatenate .xz files as is. xz will decompress such files as if they were a single .xz file.

From my tests, this works even if the different files are compressed with different options; so in your case

cat *.log.xz > newfile.log.xz

will work fine.

To answer your more general question, you can pipe the output of a compound command, e.g.

for file in *.log.xz; do xzcat "$file"; done | xz -ve9 > newfile.log.xz

or any subshell. This would allow you to perform any processing you want to on your log files before recompressing them. However in the basic case this isn’t necessary either; you can decompress and recompress all your files by running

xzcat *.log.xz | xz -ve9 > newfile.log.xz

If you add -f this even works with uncompressed files, so

xzcat -f uncompressed.log *.log.xz | xz -ve9 > newfile.log.xz

would allow you to combine uncompressed and compressed logs.

Source Link
Stephen Kitt
  • 481.4k
  • 60
  • 1.2k
  • 1.4k

The xz documentation says

It is possible to concatenate .xz files as is. xz will decompress such files as if they were a single .xz file.

From my tests, this works even if the different files are compressed with different options; so in your case

cat *.log.xz > newfile.log.xz

will work fine.

To answer your more general question, you can pipe the output of a compound command, e.g.

for file in *.log.xz; do xzcat "$file"; done | xz -ve9 > newfile.log.xz

or any subshell. However in this case this isn’t necessary either; you can decompress and recompress all your files by running

xzcat *.log.xz | xz -ve9 > newfile.log.xz