Decompress (with gunzip) recursively, but do not delete original gz file
Hi all,
I have a folder hierarchy with many gz files in them. I would like to recursively decompress them, but keep the original files. I would also like to move all the decompressed files (these are very large HDF5 files with .CP12 extension) to another data folder.
Currently I am using four steps to achieve this:
1. Make a copy of the source directory hierarchy:
2. Inside new_archive, gunzip recursively:
3. Move all decompressed files from new_archive hierarchy to a data folder:
4. Remove new_archive (empty hierarchy)
This works. old_archive contains gz files and data contains the decompressed versions. But is time consuming.
My question is: how can I perform this recursive extraction efficiently? I would like to avoid step 1, since it takes a very long time (terabyte size datasets).
I need to prevent gunzip's default behavior (removing the original gz file). Since, grep -d or gunzip has a "-c" option to extract to stdout, how I can recursively extract and put in data?
If I write a simple shell script for this, would running gunzip -c hdf-file.gz> hdf-file recursively be more efficient that doing cp and then gunzip? Note that the decompressed files can be very big (gigabyte size each) and so I also want to prevent sized related errors during the pipe process. Could someone comment on this. Thanks in advance!
---------- Post updated at 06:21 PM ---------- Previous update was at 06:03 PM ----------
Here is another script version for the same:
Is there a better way?
Last edited by gansvv; 01-12-2011 at 07:26 PM..
Reason: added another version
Hello evrebody ,
I have HPUX-11, i try to install "Mozilla" and "unzip utillity"
I cannot decompress file (F.tar.gz) or file(F.gz) by commandes:
gunzip -dv F.tar.gz | tar -xvf
gunzip F.tar.gz
or
gzip -dv F.tar.gz |tar -xvf
gzip F.gz
maybe someone know What's the reason?
maybe i... (1 Reply)
Hi to all, I'm new in this forum and I just need a quick answer from the experts out there, I have a 2761.sp file, in short a ".SP" file, it was given to me compressed, and I need to decompress it before Monday. I saw a software named Splint, but it shows an error, a DMI error message, so I dont... (3 Replies)
In a bash script:
src=”cooltrack.wav”
dst=”cooltrack.mp3”
lame $src $dst
I would like to add some line that would delete the source wav file like:
rm $src
but I would like this only if the encoding was successful.
What should I include before deleting the original to check that the... (2 Replies)
Hi,
I have a zipped Oralce software (linux.x64_11gR1_database.zip) and I need to unzip it. On the Linux server, I only see the gunzip utility listed:
$ ls -ltr *zip*
-rwxr-xr-x 3 root root 60320 Jan 15 2008 gzip
-rwxr-xr-x 3 root root 60320 Jan 15 2008 gunzip
Can I use the command... (1 Reply)
i have 200000bytes size of a unix file i need to delete some text between two strings recursively using a loop with sed or awk . these two strings are : 1st string getting from a file :::2 nd string is fi...its constant . can anyone help me sed -n'/<1 st string >/,/fi/' <input_filename> is the... (2 Replies)
Hi,
I want to delete all empty directories in a long directore tree structure. I want to use that from a script that will run on HP-UX 11. My definition of empty directory is that there is no regular file under it and directly beneath it. To elaborate, I have below directories.
/app/dev/java... (14 Replies)
I am completely new to shell scripting but have been assigned the task of creating several batch files to manipulate data. My final task requires me to find lines that have duplicates present then delete not only the duplicate but the original as well. The script will be used in a windows... (9 Replies)
I have compressed files under directory '/root/data' and i need the uncompressed files in another directory
'/root/uncom'. I running a shell script below shell script from directory '/root/'
gunzip /root/data/*.gz -d /root/uncom
But this is failing with
gunzip: /root/uncom is a directory... (2 Replies)
I have compressed files under directory '/root/data' and i need the uncompressed files in another directory
'/root/uncom'. I running a shell script below shell script from directory '/root/'
gunzip /root/data/*.gz -d /root/uncom
But this is failing with :
gunzip: /root/uncom is a directory... (2 Replies)