Solved

Need gzip examples in pipe

Posted on 2004-09-09
8
6,045 Views
Last Modified: 2008-03-10
For a learning purposes I search a simple examples for using gzip in pipe
with basic linux commands
Something like
......   | gzip -c > .....
or
......   | gzip -d > .....


(not only tar nor , I need a factics output for any simple Linux commands )
Can anybody help me quick ???

Thanks
Petr

0
Comment
Question by:hatina
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 45

Expert Comment

by:sunnycoder
ID: 12014726
Hi hatina,

check gzip man page for more examples
cat file1 file2 | gzip > foo.gz
gzip -cd old.gz | gzip > new.gz

Sunnycoder
0
 

Author Comment

by:hatina
ID: 12014966
I do not need simple gzip using,...
I need a practical examples cooperative with another Linux commands through pipe.........!!!!!!!!!!!!
0
 
LVL 45

Expert Comment

by:sunnycoder
ID: 12014994
Which commands ?? The above are as good as practical exmaples ... you can complicate either side of pipe as much as you desire

cat file1 file2 | gzip > foo.gz

can be morphed to

find <some_dir> -type f -name "foo" -exec car {} \; | gzip > total_foo.gz
0
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
LVL 45

Expert Comment

by:sunnycoder
ID: 12014998
find <some_dir> -type f -name "foo" -exec cat {} \; | gzip > total_foo.gz
                                                                 ^
0
 

Expert Comment

by:cuspoon
ID: 12018997
There is always the simple

gzip -c (file.tgz) | tar xvf -
0
 

Expert Comment

by:cuspoon
ID: 12019041
I hate it when fingers slip off the keys...   There is a missing key in there.

gzip -cd (file.tgz) | tar x

or for those of us who like output

gzip -cd (file.tgz) | tar xv

or still

gzip -cd (file.tgz) | tar xvf -
0
 
LVL 3

Accepted Solution

by:
255x4 earned 125 total points
ID: 12028477
The pipe ( | ) command is simply a way of redirecting stdout information, and sending it to another command as if it was text being entered to it.  For gzip, this would be in place of telling gzip to compress a particular file, but rather compress the stdout data until it reaches an EOF (End Of File) statement.

Note, the pipe does not allow program interaction, it does not output the stderr signal, just stdout.  There is no way for the next program to know if something went wrong.  Nor can later programs communicate with previous programs.  This is a one way, stream only, signal.

If you wish to take stdout data, pipe it to gzip, then have that go to the stdout and possibly be piped somewhere else, then here ya go:

{command} | gzip -f | {other command}

example:

cat examplefile.txt | gzip -f |

I really can't think of anything to do with this binary stream after gzip'ing it, but if you want to, do what you will.

Thanks,
255x4
0
 
LVL 2

Expert Comment

by:Sunjith
ID: 12039447
Another practical example ;-)
Say, you have to capture all packets going through your network interface for some time and you may want to store it in an archive. You may then use a command like follows:
tcpdump -s0 -X -vv | gzip > dump.gz
(You have to kill tcpdump from another terminal. If you press Ctrl+C in the same terminal, gzip cannot close the archive properly.)
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
1. Introduction As many people are interested in Linux but not as many are interested or knowledgeable (enough) to install Linux on their system, here is a safe way to try out Linux on your existing (Windows) system. The idea is that you insta…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question