Hey all,
Extremely quick one today, but one I certainly found very useful. In some of my backup tarballs, I've ended up with some seriously deeply nested files, and extracting a single file into a folder, only to have it appear inside an otherwise completely empty 15 folder deep directory tree is pointless, and to be honest, slightly annoying. I found a snippet today which allows you to ignore a specified number of directories when extracting files...
tar --strip-components {N} -xvJf tarball.tar.xz {filename}
All you need to do is swap {N} for the number of folders to ignore, {filename} for the name of the file you wish to extract, and enter the tarball name instead of "tarball.tar.xz". Here's an example...
tar -C ~ --strip components 2 -xvJf Backups.tar.xz shares/public/code/example.php
This will extract the file "example.php" from the tarball "Backups.tar.xz", and put it in your home folder in a subdirectory called "code". To extract it to a folder called public/code, you would change the number to 1, and to put it directly in your home folder, change it to 3.
Right, off to do some work! Hope this has helped you out!!