Help in searching a multiple text in zip file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help in searching a multiple text in zip file
# 1  
Old 03-21-2012
Help in searching a multiple text in zip file

Hi Gurus,
i have 8 zipped files and each file is having more than 100,000 records or more.
Quote:
files names :- filename_20120301.gz
filename_20120302.gz
filename_20120303.gz
filename_20120304.gz

Ex:- filename_20120301.gz
Deptno ename sal
10 Alpha 900
20 Bravo 1200
30 Charlie 1000
40 Delta 900
50 Echo 800
60 Foxtrot 1100
70 Golf 1200
80 Hotel 1500
90 India 1300
issue :-

i want to search the missing text from each zipped files

i have stuck here, the below command works fine if i give the value 10 for the deptno.

if i have more than 1 records 20,30,40,50,60 to search in .gz file

Quote:
gunzip -c filename_20120301.gz | grep -n -i "10"
Please share the solution for this

Thanks in advance
# 2  
Old 03-21-2012
maybe you can try 'egrep'.

egrep 'text1|text2'
# 3  
Old 03-21-2012
Quote:
Originally Posted by daWonderer
maybe you can try 'egrep'.

egrep 'text1|text2'
thanks dude,

actually i have tried in grep, but i have no luck on this.

now its working fine by giving the
Quote:
egrep


can you please share the "file name" to be print too...
# 4  
Old 03-21-2012
Quote:
Originally Posted by SeenuGuddu
can you please share the "file name" to be print too...
guess you will be using a script to iterate through unknown list of zipped files.

it is possible to use command in a loop with 'for'. for filename in $(ls /thePath/*.gz) ...

in this loop it is possible to assign result of a command to a variable. yourVar=$(gunzip -c $filename | egrep 'txt1|txt2')

now you can check if '$yourVar' is empty or not and echo filename and result of 'egrep'.
# 5  
Old 03-21-2012
see the zgrep command
# 6  
Old 03-21-2012
Quote:
i want to search the missing text from each zipped files
Personally I don't understand this sentence.

Please post Expected Output to match your Sample Data.
If you only want to match on the Deptno field, the egrep (or if you have the command zegrep) needs to be more specific or you will get accidental matches with other fields.
# 7  
Old 03-21-2012
zegrep doesnt work in my Bash.. Can any one throw some light on getting it in my bash shell???

Please help, i have a similar kinda requiremant.

Thanks,
Mahi
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Grep a pattern from zip file which has multiple files insdie

Hi Gurus, I got a small requirement in my script to grep a specific pattern in a zip compressed file which has been created with multiple files. Sample File: 20180913.zip $> zipinfo -l 20180913.zip 20180913_file1 20180913_file2 20180913_file3 20180912_file4 20180912_file5... (1 Reply)
Discussion started by: hi.villinda
1 Replies

2. Shell Programming and Scripting

How can we Zip multiple files created on the same date into one single zip file.?

Hi all i am very new to shell scripting and need some help from you to learn 1)i have some log files that gets generated on daily basis example: i have abc_2017_01_30_1.log ,2017_01_30_2.log like wise so i want to zip this 4 logs which are created on same date into one zip folder. 2)Post zipping... (1 Reply)
Discussion started by: b.saipriyanka
1 Replies

3. UNIX for Beginners Questions & Answers

How can we Zip multiple files created on the same date into one single zip file.?

Hi all i am very new to shell scripting and need some help from you to learn 1)i have some log files that gets generated on daily basis example: i have abc_2017_01_30_1.log ,2017_01_30_2.log like wise so i want to zip this 4 logs which are created on same date into one zip folder. 2)Post zipping... (2 Replies)
Discussion started by: b.saipriyanka
2 Replies

4. Shell Programming and Scripting

Zip Multiple files to One .zip file in AIX system

Hi I have a requirement in unix shell where I need to zip multiple files on server to one single .zip file. I dont see zip command in AIX and gzip command not doing completely what I want. One I do .zip file, I should be able to unzip in my local Computer. Here is example what I want... (9 Replies)
Discussion started by: RAMA PULI
9 Replies

5. UNIX for Dummies Questions & Answers

archieve and zip the multiple file with no extension

Hi, I'm new to scripting. I need to find all the 10 files in the source directory and then archieve them to archive directory. The source files which im getting does not have any extensions just binary files. I need to find them by the file names and archive it. Directory also contains other... (1 Reply)
Discussion started by: etldeveloper
1 Replies

6. UNIX for Dummies Questions & Answers

Searching for Multiple texts in a file

Hello guys, I hope anyone can help me with this ... I have a file in which i have around 6000 lines of same format text like 1234567 2345678 3456789 .................... Now what I have to do is that there I have to search these numbers in another file which contains hundreds of... (1 Reply)
Discussion started by: m_usmanayub
1 Replies

7. Shell Programming and Scripting

searching a file with a specified text without using conventional file searching commands

without using conventional file searching commands like find etc, is it possible to locate a file if i just know that the file that i'm searching for contains a particular text like "Hello world" or something? (5 Replies)
Discussion started by: arindamlive
5 Replies

8. Shell Programming and Scripting

Searching for multiple patterns in a file

Hi All, I have a file in which i have to search for a pattern from the beginning of the file and if the pattern is found , then i have to perform a reverse search from that line to the beginning of the file to get the first occurrence of another pattern. sample input file hey what are you... (8 Replies)
Discussion started by: Kesavan
8 Replies

9. Shell Programming and Scripting

Full text searching for multiple items

I am trying to find a solution to a request here at work. I have been asked to do a full text search of around 300,000 files for multiple content items. The following words need to appear in the file. (april and\or may) and pie and (red and\or white). So a file with the words april... (6 Replies)
Discussion started by: kondoor
6 Replies

10. AIX

ZIP multiple files and also specify size of zip file

I have to zip many pdf files and the size of zip file must not exceed 200 MB. When size is more than 200 MB then multiple zip files needs to be created. How we can achieve this in UNIX? I have tried ZIP utility but it takes a lot of time when we add individual pdfs by looping through a... (1 Reply)
Discussion started by: tom007
1 Replies
Login or Register to Ask a Question