I have tried everything i know and dozens of old forum posts on this kind of thing...nothing is working.
I have uploaded a backup wordpress directory to web server after the existing one was inadvertantly deleted.
I dont know why, however, the way in which the backup has archived seems weird and i am unable to get the damn thing to decompress properly.
At best, the methods i am currently using decompresses all wordpress directories/subdirectories but ALL the files inside them remain compressed with ".gz" file extension.
there are more than 500 files in subfolders to perform this task on.
Can someone provide me with a simple and straight forward answer on how to achieve this task?
I can get part of the way with the following code, however, it won't go recursively into non compressed subfolders looking for more ".gz" files to decompress (note...folders/subfolders are already decompressed but not files in them).
for f in wordpress/.gz ; do gunzip $f ; done*
You can achieve this with
find
(See: manpage) and its-exec
flag. for tar archives the following line will do the trick:For gunzip you can use:
If there are both file-types you need to do this kind of different a bit, first run gunzip without the
-k
(keep file) flag and then run the find line for tar files as well a tiny bit changed:to add to the answer i marked as correct for me...here is the code a friend posted for me to copy and his instructions.
from the public_html/ directory, i tried both of the following code options.
for f in wordpress/.gz ; do gunzip $f ; done*
the above would mean that in order to get down more than one sublevel i would need to enter it over and over again by adding more subdirectories e.g wordpress/subdirectory/*.gz, wordpress/subdirectory/subdirectory/... etc.
The simplest option is this one below...Test first with
find wordpress/ -name "*.gz" -exec ls -lh {} \;
ls -lh does not break anything but you see what files it would mess. If the files are the correct ones, change ls -lh to gunzip.
find wordpress/ -name "*.gz" -exec gunzip {} \;
Read
man find
,man xargs
, and do something like this:For testing, replace
gunzip
withecho gunzip
Add to the answer by @videonauth:
If you want to untar the .tar.gz files in subfolders into the same sub-folder instead of the root folder where you run the command, you can use the -execdir option: