Solved

Need gzip examples in pipe

Posted on 2004-09-09
8
6,016 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
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
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 
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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

773 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