zgrep cannot find all matches


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting zgrep cannot find all matches
# 1  
Old 06-27-2012
zgrep cannot find all matches

Code:
$ cat 1.csv
abc in csv
$ cat 1.mnf
abc in mnf
$ zip 1.zip 1.csv 1.mnf
  adding: 1.csv (stored 0%)
  adding: 1.mnf (stored 0%)
$ zgrep abc 1.zip
abc in csv

How come zgrep cannot find "abc in mnf"?
Thanks in advance.

Last edited by Franklin52; 06-27-2012 at 07:11 AM.. Reason: Please use code tags for data and code samples
# 2  
Old 06-27-2012
check this out.....

this very strange i don't what is reason for this....

Code:
 zcat 1.zip
abc in csv
zcat: 1.zip has more than one entry--rest ignored
$

This User Gave Thanks to pamu For This Post:
# 3  
Old 06-27-2012
Hi.

On my system:
Code:
OS, ker|rel, machine: Linux, 2.6.26-2-amd64, x86_64
Distribution        : Debian GNU/Linux 5.0.8 (lenny)


The command zgrep is a shell script:
Code:
% file /bin/zgrep
/bin/zgrep: POSIX shell script text executable

It calls gzip. In the man page for gzip:
Code:
       Files created by zip can be uncompressed by gzip only if they have a
       single member compressed with the 'deflation' method. This feature is
       only intended to help conversion of tar.zip files to the tar.gz format.
       To extract a zip file with a single member, use a command like gunzip
       <foo.zip or gunzip -S .zip foo.zip.  To extract zip files with several
       members, use unzip instead of gunzip.

-- excerpt from man gzip

The man pages are your firends.

Best wishes ... cheers, drl
This User Gave Thanks to drl For This Post:
# 4  
Old 06-29-2012
Understood and thanks.
But how do I make zgrep call unzip instead of gzip?
# 5  
Old 06-29-2012
Bug You can do this....

I know this is not the efficient way of doing this. You might get good solution here from the gurus...

lets try this..

Code:
cat `unzip 1.zip | grep "extracting:" | awk '{ print $2 }'`

# 6  
Old 06-29-2012
You could also do like this.

Code:
unzip -p 1.zip | grep ...

This User Gave Thanks to clx For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find a text and if condition matches then replace it

Need a script that can find text in a file and replace it accordingly. This is the file I have: while IFS=',' read -r f1 f2 f3 do { nohup /home/testuser/dbmaintenance/sys_offline_maintenance.sh $f1 $f2 $f3 > $f2.out & } done < "/home/testuser/dbmaintenance/week1offlineserver.txt" In... (4 Replies)
Discussion started by: singhhe
4 Replies

2. UNIX for Beginners Questions & Answers

find pattern matches in consecutive lines in certain fields-awk

I have a text file with many thousands of lines, a small sample of which looks like this: InputFile:PS002,003 D -1 5 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 6 6 -1 -1 -1 -1 0 509 0 PS002,003 PSQ 0 1 7 18 1 0 -1 1 1 3 -1 -1 ... (5 Replies)
Discussion started by: jvoot
5 Replies

3. Shell Programming and Scripting

Find matches and write the data before it

Hi all I am here for help once again I have two files One file is like this with one columns F2 B2 CAD KGM HTC CSP Second file is like this in 5 columns where firs column contain sometime entries of first file with space and other entries (12 Replies)
Discussion started by: Priyanka Chopra
12 Replies

4. Shell Programming and Scripting

Find file that matches today's date in filename and move to /tmp in bash

I'm having problems with my bash script. I would like to find a file matching today's date in the filename, i.e. my_file_20120902.txt and then move it to a different directory, i.e. /tmp. Thanks. (1 Reply)
Discussion started by: jamesi
1 Replies

5. Shell Programming and Scripting

Find directories that contains more than n matches of a certain filename

I need to construct a command that finds directories which contains more than n matches of a certain filename. E.g. I have many directories at different locations and want to find all directories that has 2 or more .dat-files. I thought of using find and maybe the exec parameter to issue an... (5 Replies)
Discussion started by: odyssey
5 Replies

6. Shell Programming and Scripting

find/grep returns no matches

Hi all! I've faced with very unintelligible error using find/grep like this: root@v29221:~# find /var/www/igor/data/www/lestnitsa.ru | grep u28507I get nothing as a result, but: root@v29221:~# grep u28507 /var/www/igor/data/www/lestnitsa.ru/_var.inc $db_name = 'u28507';... (2 Replies)
Discussion started by: ulrith
2 Replies

7. Shell Programming and Scripting

Need to find a string, check the next line, and if it matches certain criteria, replace it with a s

Hey Fellas. I am new to scripting. I have searched through the forums and found a lot of good info, but I can't seem to get any of it to work together. I am trying to find a particular sting in a file, and if the next string matches certain criteria, replace it with a string from a csv... (6 Replies)
Discussion started by: midniteslice
6 Replies

8. Shell Programming and Scripting

find matches in file

Hi, im have log file ~100000 lines, 192.168.29.1 at 10/08/09 13:58:55 192.168.60.1 at 10/08/09 14:11:28 192.168.58.171 at 10/08/09 14:12:45 192.168.61.12 at 10/08/09 14:15:44 192.168.60.1 at 10/08/09 14:16:36 192.168.60.1 at 10/08/09 14:17:43 192.168.61.12 at 10/08/09 14:18:08... (9 Replies)
Discussion started by: Trump
9 Replies

9. UNIX for Dummies Questions & Answers

Zgrep equivalent-

Hi guys I cant use zgrep on a SunOS Do you know any alternative for it? i need to use zgrep -c grep works fine but zgrep is not supported (4 Replies)
Discussion started by: khestoi
4 Replies

10. Shell Programming and Scripting

help using zgrep

can any body help me i want to find 200 numbers(telephone numbers) in current directory with all sub directories with file name dump*.gz i am having 3000 .gz files to be searched i tried this command find . -name "dump*.gz" -exec zgrep -e '9425376533' {} \; but no result ... (3 Replies)
Discussion started by: shishir
3 Replies
Login or Register to Ask a Question