Visit Our UNIX and Linux User Community


Compression and decompression in the same script


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Compression and decompression in the same script
# 1  
Old 08-31-2009
Compression and decompression in the same script

Hi Guys,

I'm just wondering how to compress and decompress a file in the same script using multiple programs, and can it be done in one line?

e.g gzip file && gunzip file
bzip2 file && bunzip file

I tried this and a few other combinations but it doesn't seem to work. Any thoughts?

Cheers Spaulds
# 2  
Old 08-31-2009
Code:
gzip file && gunzip file

should just work.
Alternatively:
Code:
gzip < file | gunzip > file1

# 3  
Old 08-31-2009
Cheers, there must be an error in my script.

---------- Post updated at 01:34 AM ---------- Previous update was at 01:20 AM ----------

Sweet, got it working!

Can you display the sorterd attributes of the compression programs with somethng like:

awk'{$1 $2 $3}' | sort -n
# 4  
Old 08-31-2009
Please elaborate on what you are looking for.
# 5  
Old 08-31-2009
looking to display:

-compression program | compression size | decompression size | compression ratio
# 6  
Old 08-31-2009
The compression ratio will equal the (de)compression one for lossless algorithms like gzip and bzip.
The decompressed file size will equal the original file size.

To get statistics, use the -v option.
# 7  
Old 08-31-2009
No probs, cheers for the help!
 

Previous Thread | Next Thread
Test Your Knowledge in Computers #542
Difficulty: Medium
A globally scoped variable is invalid throughout the entire program.
True or False?

9 More Discussions You Might Find Interesting

1. Post Here to Contact Site Administrators and Moderators

VPM decompression algorithm +++for NEO+++

Hi Neo, i have followed your porting of the VPM algorithm to C+. Did you ever finish this exercise? I am playing around with some ARM chips and would love to run the algorithm on them... would you care to share the final results? Thanks for your help. Greetings Carsten (0 Replies)
Discussion started by: carsten
0 Replies

2. Solaris

ZCAT xxx.Z|tar -xvf - decompression slow ?

I have recently built a new server and patched Soalris 10 up tp latest bundle etc... When I run a decompress using the format zcat fred.Z |tar -xvf - it runs at a very slow rate. A similiar server which is less powerful runs over twice as quick. Is there any work arounds to configure decompress... (4 Replies)
Discussion started by: smcart
4 Replies

3. What is on Your Mind?

Port VPM Decompression Algorithm to PHP (Main Loop) - Part 2

Continued from here. Port the main loop C code to PHP. Here is the C code for the main loop: /* =============================================================================== */ /* Begin MAIN proc (see endofpgm for alternate entry) */ /*... (2 Replies)
Discussion started by: Neo
2 Replies

4. What is on Your Mind?

Port VPM Decompression Algorithm to PHP and then to Dive Computer

Hello! I'm about to embark on a new project to port the VPM (Variable Permability Model) for decompression diving from some old BASIC code (attached, "VPM.txt") to PHP. Then, I plan to create a plugin for this site where folks can run VPM on the web. Then, I plan to improve VPM based on... (15 Replies)
Discussion started by: Neo
15 Replies

5. Shell Programming and Scripting

Folder compression

Hi Guys, totally new to scripting. I have a huge list of foleders. I want to tar the contents of each folder inside the same folder and the name of the tar file is the same name as the folder. how would I go about this in scirpt? cheers Viper (3 Replies)
Discussion started by: brownviper1966
3 Replies

6. UNIX for Advanced & Expert Users

GNU tar automatic gz detection/decompression

I stumbled on this feature on a SLES10 system yesterday... if you tar tf filename.tar.gz or tar xf filename.tar.gz it automatically gunzips the data for you. Has this feature been around for a while? I have 1.12 on my system, which doesn't, but the 1.20 manual mentions it... (3 Replies)
Discussion started by: Annihilannic
3 Replies

7. Shell Programming and Scripting

Shell Script - compression

Hello all, i am a complete beginner when it comes to unix and shell scripting. I want to be able to compress a file (ff) with a shell script for example the command would look like compress.sh ff then with the script have the file compressed using the zip, gzip and compress commands. I... (1 Reply)
Discussion started by: noodlesoup
1 Replies

8. Windows & DOS: Issues & Discussions

Decompression with Cygwin

I am having some trouble decompressing a tar.bz2 with Cygwin. Is it even possible to do this? I am new to Unix so I have no idea. I downloaded GCC on my Windows machine (gcc-3.4.4.tar.bz2) and I've been trying to decompress and install it. Is cygwin this best way to decompress on a windows... (3 Replies)
Discussion started by: noob1021
3 Replies

9. UNIX for Dummies Questions & Answers

Decompression utility

I am looking for an unzip application that can handle Unix .z files, but from a Windows environment AND has a command-line prompt. Anybody know of anything? TIA, H2M3 (2 Replies)
Discussion started by: H2M3
2 Replies

Featured Tech Videos