"xz" syntax to create a ".txz" file

I have a file named "test.tar". I want to compress it with the xz command.

If I use the following command, the result would be a file named "test.tar.xz":

Code:
xz test.tar

I want a file named "test.txz" (instead of "test.tar.xz"). What command would it take to achieve this?

Note:
I am aware that I could use the tar command to create an xz compressed archive, but I'm curious with the xz syntax.
I'm also aware that I could create a "test.tar.xz" file and just rename it to "test.txz", but I don't want to do that either.
I want to know the exact xz syntax to create a ".txz" file, since (by default) the xz command wants to create ".xz" files only.
 
Niatross said:
I am aware that I could use the tar command to create an xz compressed archive, but I'm curious with the xz syntax of how I would achieve this.
Reading the xz(1) man page usually helps:
Code:
       -S .suf, --suffix=.suf
              When compressing, use .suf as the suffix  for  the  target  file
              instead  of .xz or .lzma.  If not writing to standard output and
              the source file already has the suffix .suf, a warning  is  dis-
              played and the file is skipped.
 
That doesn't get me what I want. That would give me a file named: "test.tar.txz". I'm looking for "test.txz".

The suffix option only adds a suffix to a filename that already has a suffix (ex: .tar).

Anyone else?
 
There appears to be no option to have xz() directly change the suffix of the filename like you want.
Use a little redirection:
Code:
xz -c -z test.tar > test.txz
 
Back
Top