I’ve written on compressing files with XZ algorithm. If you had done so already, you would’ve noticed by now that using that command line by line will cause the program to create an archive with all of its parent folders included.
If you run a command from the previous post to compress ‘/home/username/documents/compress-me.txt’, it will create folder hierarchy within, thus opening the file will recreate the parent folders. There are two solutions to this:
Solution 1: cd into the folder
Using the earlier example, after you have narrowed down the directory, simply run the command. This is the simplest solution. But sometimes cd into any random directories may not be affordable.
Solution 2: use -C option in tar command: e.g. "tar -cJf [path to archive].tar.xz -C [path to files] [files]"
This command will disregard any parent folders you may have inadvertently added.