Solved

Need gzip examples in pipe

Posted on 2004-09-09
8
6,036 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
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 
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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
CentOS 7 Linux for HP DL380 G4 32Bits 7 101
Samba 4, Users Permission, 5 111
Looking for a program called HoneyMine. 3 117
Golang on CentOS / Fedora 2 6
The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
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.
Suggested Courses

737 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