Find Multiple Strings from a list of *.gz files withour decompressing...


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Find Multiple Strings from a list of *.gz files withour decompressing...
# 1  
Old 07-13-2011
Find Multiple Strings from a list of *.gz files withour decompressing...

Hello Team,

There is this situation where there are around 20 *.gz files and i want to search multiple words from all those files.

Example as below :

filea.gz

fileb.gz

filec.gz


now i want to search words "hi" and "hello" from all these 3 files without decompressing them in a single command.

I tried :


zgrep hi *.gz and zgrep hello *.gz .

but i dont know how could i apply search for "hi" and "hello" in only one command....


I also tried zgrep "hi | hello" *.gz but it didn't work.

Please suggest how can i find multiple words without decompressing *.gz files....
# 2  
Old 07-13-2011
read man command of zgrep

and look for -E option
# 3  
Old 07-13-2011
I alrdy checked the man command of zgrep... cant really workout...

plz help me to resolve..
# 4  
Old 07-13-2011
Code:
 
zgrep -E "hi|hello|how" *.gz

This User Gave Thanks to itkamaraj For This Post:
# 5  
Old 07-13-2011
Thanks buddyy....

I know my mistake... I was giving spacebar between the two options... as a result it was not working... Now its working.. :-)
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to pass strings from a list of strings from another file and create multiple files?

Hello Everyone , Iam a newbie to shell programming and iam reaching out if anyone can help in this :- I have two files 1) Insert.txt 2) partition_list.txt insert.txt looks like this :- insert into emp1 partition (partition_name) (a1, b2, c4, s6, d8) select a1, b2, c4, (2 Replies)
Discussion started by: nubie2linux
2 Replies

2. UNIX for Beginners Questions & Answers

Using find to output list of files with specific strings

This is my problem, I am using the following code to extract the file names with specific strings 0.01: find ./ -name "*.txt" -exec grep -H '0.01' {} + It works wonders with a small sample. However, when I use it in a real scenario it produces an empty file -even though I am sure there are... (11 Replies)
Discussion started by: Xterra
11 Replies

3. Shell Programming and Scripting

Grep strings on multiple files and output to multiple files

Hi All, I want to use egrep on multiple files and the results should be output to multiple files. I am using the below code in my shell script(working in Ksh shell). However with this code I am not attaining the desired results. #!/bin/ksh ( a="/path/file1" b="path/file2" for file in... (4 Replies)
Discussion started by: am24
4 Replies

4. Shell Programming and Scripting

Search & Replace: Multiple Strings / Multiple Files

I have a list of files all over a file system e.g. /home/1/foo/bar.x /www/sites/moose/foo.txtI'm looking for strings in these files and want to replace each occurrence with a replacement string, e.g. if I find: '#@!^\&@ in any of the files I want to replace it with: 655#@11, etc. There... (2 Replies)
Discussion started by: spacegoose
2 Replies

5. Shell Programming and Scripting

How to find multiple strings within files under a directory

Hi guys, I need to find multiple strings within files under a directory and secondly, to count how many files are there with these strings. At present, i am able to do this in order to find one string (for example "abc"): find <path> -exec grep "abc" {} /dev/null \; Now for example, i... (2 Replies)
Discussion started by: frum
2 Replies

6. UNIX for Dummies Questions & Answers

how to find and replace strings in multiple files

Hi All, Iam new to unix, I need to find string and replace it in the file name. Like text_123_0.txt,text_123_1.txt,text_123_2.txt. I need to search 123 and replace it with 234 . Is there any unix command to replace them in single command since i have 5 directories. So i need to go each and every... (0 Replies)
Discussion started by: etldeveloper
0 Replies

7. UNIX for Dummies Questions & Answers

Grep multiple strings in multiple files using single command

Hi, I will use below command for grep single string ("osuser" is search string) ex: find . -type f | xarg grep -il osuser but i have one more string "v$session" here i want to grep in which file these two strings are present. any help is appreciated, Thanks in advance. Gagan (2 Replies)
Discussion started by: gagan4599
2 Replies

8. UNIX for Dummies Questions & Answers

grep command to find multiple strings in multiple lines in a file.

I want to search files (basically .cc files) in /xx folder and subfolders. Those files (*.cc files) must contain #include "header.h" AND x() function. I am writing it another way to make it clear, I wanna list of *.cc files that have 'header.h' & 'x()'. They must have two strings, header.h... (2 Replies)
Discussion started by: ritikaSharma
2 Replies

9. UNIX for Dummies Questions & Answers

best method of replacing multiple strings in multiple files - sed or awk? most simple preferred :)

Hi guys, say I have a few files in a directory (58 text files or somthing) each one contains mulitple strings that I wish to replace with other strings so in these 58 files I'm looking for say the following strings: JAM (replace with BUTTER) BREAD (replace with CRACKER) SCOOP (replace... (19 Replies)
Discussion started by: rich@ardz
19 Replies

10. Shell Programming and Scripting

To view .gz files without decompressing it

hi, I have a file called Archiver1.gz how to view this file without doing gunzip on it i.e. decompressing it i tried this command but its not working: gzcat Archiver1.gz | tail -10 (4 Replies)
Discussion started by: ali560045
4 Replies
Login or Register to Ask a Question