less tar-extract-file-examples.md
tar: extract file examples
# historical archive — written years ago, kept as it was. Some info is dated.
Some of my sites have by now reached considerable sizes, and hunting through backup archives for a single file is becoming increasingly complicated.
The first reason is that the archives are, to save space, in .tar.gz or tar.bz2 format.
The second reason is that extracting an entire archive for a single file is pointless.
To get a better result, the following command string comes in absolutely handy. It will also help you if you don’t remember exactly the location and name of the file.
tar xzvf ../archivioweb_2017-06-10_00-14.tar.gz --wildcards --no-anchored '*wp-config*'
The following will also let you choose the destination directory for the file you are going to extract
tar xzvf ../web11_2017-06-10_00-14.tar.gz -C /new_directory/ --wildcards --no-anchored '*wp-config*'