Using piped input to gzip


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Using piped input to gzip
# 1  
Old 12-01-2010
Using piped input to gzip

Can anyone tell me why does'nt the following command work?

Code:
find /gfp1/home/arijit -name "*.sas7bdat" | gzip


I am trying to compress all files with extension sas7bdat with gzip.

It gives error message

Code:
gzip: compressed data not written to a terminal. Use -f to force compression.
For help, type: gzip -h


Last edited by pludi; 12-01-2010 at 07:01 AM.. Reason: code tags, please...
# 2  
Old 12-01-2010
When piping to gzip it will compress the data stream it receives, not read a list of file names to compress. As such, it won't write the compressed stream to a TTY, you'll have to redirect either to another program or a file.

To do what you want, use this:
Code:
find /gfp1/home/arijit -name "*.sas7bdat" -exec gzip {} \;

This User Gave Thanks to pludi For This Post:
# 3  
Old 12-01-2010
Quote:
Originally Posted by pludi
When piping to gzip it will compress the data stream it receives, not read a list of file names to compress. As such, it won't write the compressed stream to a TTY, you'll have to redirect either to another program or a file.

To do what you want, use this:
Code:
find /gfp1/home/arijit -name "*.sas7bdat" -exec gzip {} \;

thanks,

But can u pls explain the exec command>.......

never heard of it before...
# 4  
Old 12-01-2010
Here is correct approch
Code:
find /home/test/  -type f -name "file*"  -exec gzip {} \;

OR in your case
Code:
find /gfp1/home/arijit -name "*.sas7bdat"  -exec gzip {} \;

This User Gave Thanks to mtomar For This Post:
# 5  
Old 12-01-2010
or try with xargs..
Code:
find /gfp1/home/arijit -name "*.sas7bdat" | xargs gzip

# 6  
Old 12-01-2010
Depending on your OS you can also check whether your gzip version support the -@ option
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Getting piped input from a program that's buffering it's stdout

The old buffering problem again, in a very specific case. On FreeBSD this time, but it's the generic line-buffered vs fully-buffered problem. I'm trying to pick an available bluetooth speaker (all named audio_N), by pinging all of them en mass and taking the first to respond. The... (10 Replies)
Discussion started by: Juha Nurmela
10 Replies

2. Shell Programming and Scripting

Help with curl piped to awk

Greetings!! am trying to retrieve a particular section from the url as in url.txt.. aim is to get the 83.8 MB as output, but somehow this is not happening!, please suggest what might be wrong.. attached is the screenshot and text file of the page source. Best Regards, Vinu (14 Replies)
Discussion started by: vinu2k3
14 Replies

3. Shell Programming and Scripting

Perl: How to check if there is something being piped in

Hi, I am somewhat new to Perl and currently checking it out. I have a problem testing, if there is nothing being piped in to that script. I am reading input from STDIN this way: while( defined($line = <STDIN>) ) { chomp($line); if( $line =~ m/($ARGV)/g ) { ... (7 Replies)
Discussion started by: zaxxon
7 Replies

4. Shell Programming and Scripting

Help with Bash piped while-read and a read user input at the same time

Hi I am new to writing script and want to use a Bash Piped while-read and read from user input. if something happens on server.log then do while loop or if something happend on user input then do while loop. Pseudocode something like: tail -n 3 -f server.log | while read serverline || read... (8 Replies)
Discussion started by: MyMorris
8 Replies

5. Shell Programming and Scripting

Cat piped output

Hello, How can I efficiently cat piped output with another file? > (awk command) | cat file1 (piped output) Thanks! (11 Replies)
Discussion started by: palex
11 Replies

6. Programming

How to use a debugger a piped program ?

Hi, I have 1 program that writes in to the STDIN of another program as shown below. Both programs contain 4 or 5 lines & would terminate in under a second. $ driver.exe | program.exe How is that I can attach the debugger (gdb) to program.exe ? so that I can step through and see what all... (0 Replies)
Discussion started by: RipClaw
0 Replies

7. UNIX for Advanced & Expert Users

gzip vs pipe gzip: produce different file size

Hi All, I have a random test file: test.txt, size: 146 $ ll test.txt $ 146 test.txt Take 1: $ cat test.txt | gzip > test.txt.gz $ ll test.txt.gz $ 124 test.txt.gz Take 2: $ gzip test.txt $ ll test.txt.gz $ 133 test.txt.gz As you can see, gzipping a file and piping into gzip... (1 Reply)
Discussion started by: hanfresco
1 Replies

8. Shell Programming and Scripting

Piped input to sed 's/\n/ /' doesn't remove the line breaks..

Using ls input as example.. ls | sed 's/\n/ /'outputs with line breaks, where I was expecting the \n to disappear. I've tried \r as well wondering if terminal output used different breaks. Is there a way to remove the line breaks without saving to file and then working from there? ----------... (2 Replies)
Discussion started by: davidpbrown
2 Replies

9. UNIX for Dummies Questions & Answers

gzip produces different output from the same input

Hi there, I'm puzzled. Compressing the same file (same name, same md5sum) at two different times will produce a different output. I mean the md5sum of the resulting .gz files are different. Does it make any sens to any of you? I'd like some explanations if you know what's going on. Thanks... (4 Replies)
Discussion started by: chebarbudo
4 Replies

10. Shell Programming and Scripting

Return value of piped command?

grep $SEARCH_STRING /etc/passwd | cut -d":" -f 1,5 I need to check the $? value of grep in the above. If I place a test for $? after the above piped command, it returns success status of grep piped to cut. How can I get the success status of grep alone? (5 Replies)
Discussion started by: krishmaths
5 Replies
Login or Register to Ask a Question