Shell script to search all entries from 1 file to all other separated files.

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Shell script to search all entries from 1 file to all other separated files.
# 8  
Old 08-26-2013
Originally Posted by Mr_47

 zgrep -f a.out maillog.*.gz > c.out
ksh: zgrep:  not found

Try gzgrep instead of zgrep
# 9  
Old 08-26-2013
fully tested, sorry wasn't aware of the non gz file. ( thanks for reminding)

now it perfectly work and most importantly I learnt something today tq again Gurus here!

[root|] gzcat mail.log.*.gz | cat - mail.log*[!g][!z] | /usr/xpg4/bin/grep -f a.out > c.out

[root] du -sh *
   1K   a.out
  15K   c.out
  18M   mail.log.02072012.gz
  94M   mail.log.10092008.gz
  19M   mail.log.16082013.gz
  97M   mail.log_current

[root] more c.out
02-Jul-2012 09:47:57.80 3e31.90fdd0.32211442 tcp_fromvirus reprocess    E 4 rfc822; <4FF0FD> mailsrv ([])
02-Jul-2012 09:47:57.89 5d62.1.99 reprocess                 D 5 rfc822; <4FF0FDEC.2090906@t> mailsrv
26-Aug-2013 12:36:05.60 6db5.1.246 reprocess                 D 992 rfc822; <521ABDDD.907070> mailsrv
26-Aug-2013 12:47:51.78 19c0.2ce850.9533558 tcp_fromvirus reprocess    E 5 rfc822; <3218DC26A184
48FA9A3986F282E30370@B12562PCTM01> mailsrv ([])
26-Aug-2013 12:47:52.17 6db5.1.270 reprocess                 D 6 rfc822; <3218DC26A18448FA9A3986
F282E30370@B12562PCTM01> mailsrv
26-Aug-2013 12:56:28.05 19c0.2cecf3.9538437 tcp_fromvirus reprocess    E 6 rfc822; <D45E34DD7994
452DA2BD89F2F33348FC@B12562PCTM01> mailsrv ([])
26-Aug-2013 12:56:28.43 6db5.1.290 reprocess                 D 6 rfc822; <D45E34DD7994452DA2BD89
F2F33348FC@B12562PCTM01> mailsrv
26-Aug-2013 14:10:38.06 19c0.2d14a9.9571984 tcp_fromvirus reprocess    E 6 rfc822; <FFF520403FF9
4D99BFB9131E27F38A9F@B12562PCTM01> mailsrv ([])
26-Aug-2013 14:10:38.55 73c8.1.48 reprocess                 D 6 rfc822; <FFF520403FF94D99BFB9131
E27F38A9F@B12562PCTM01> mailsrv
26-Aug-2013 14:19:28.03 19c0.2d19a3.9575905 tcp_fromvirus reprocess    E 6 rfc822; <1C43C9DD2B40
4E7BA46D9D3DD4D09074@B12562PCTM01> mailsrv ([])
26-Aug-2013 14:19:28.44 73c8.1.84 reprocess                 D 6 rfc822; <1C43C9DD2B404E7BA46D9D3
DD4D09074@B12562PCTM01> mailsrv
26-Aug-2013 14:27:23.15 19c0.2d1d59.9578921 tcp_fromvirus reprocess    E 6 rfc822; <F7D67C7674D6
433EB0D124AC7BB6A32F@B12562PCTM01> mailsrv ([])
26-Aug-2013 14:27:23.66 21.1.18 reprocess                 D 6 rfc822; <F7D67C7674D6433EB0D124AC7
BB6A32F@B12562PCTM01> mailsrv
26-Aug-2013 15:26:49.35 19c0.2d3fb7.9607210 tcp_fromvirus reprocess    E 150 rfc822; <02035C11A44A5E44B5C11A00BD> mailsrv ([])
26-Aug-2013 15:26:50.36 21d.1.4 reprocess                 D 151 rfc822; <02035C11A44A5E44B5C11A00BD4DB8C9076F90F> mailsrv

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to Search a string in a file in shell script?

I have a text file which is generated when the batch job is run. This batch may take few mins to run. When completed, the last line of the text file would be process completed. I need a shell script which will wait for this file till the process completed is printed in it, once found, it would move... (2 Replies)
Discussion started by: Lalat
2 Replies

2. Shell Programming and Scripting

Shell script to search all files for every string in another file

Hello All I have a pattern.txt file in source directory ((/project/source/) in linux server and data looks like: 123abc17 234cdf19 235ifg20 I have multiple log files in log directory (/project/log/) in linux server and data for one log file looks like: <?xml version="1.0" processid... (11 Replies)
Discussion started by: pred55
11 Replies

3. Shell Programming and Scripting

Need to build Shell Script to search content of a text file into a folder consist several files

Have to read one file say sourcefile containing several words and having another folder containing several files. Now read the first word of Sourcefile & search it into the folder consisting sevral files, and create another file with result. We hhave to pick the filename of the file in which... (3 Replies)
Discussion started by: mukesh.baranwal
3 Replies

4. Shell Programming and Scripting

Reading comma separated variable into other variables in shell script

Hi, In shell script, I have a variable var = xyz, inn, day, night, calif ....n and I would like to read them in to var1 = xzy, var2 = inn, var3= day, var4 = night....var. probably in a loop. I would like to read the variables until end of the line. Comma is the delimiter and there's no comma at... (3 Replies)
Discussion started by: suryaemlinux
3 Replies

5. Shell Programming and Scripting

shell script to search and copy files

Hello Im new to this forums, I would like some help regarding a script that I need in order to copy some files. Heres the scenario: I need to search several files which have a particular code inside, lets say "test" all of them on different directories. I need to copy all of them on a new... (4 Replies)
Discussion started by: c.watson
4 Replies

6. Shell Programming and Scripting

To search a file for a specific word in a file using shell script

Hi All, I have a sql output file has below. I want to get the values 200000040 and 1055.49 .Can anyone help me to write a shell script to get this. ACCOUNT_NO ------------------------------------------------------------ BILL_NO ... (8 Replies)
Discussion started by: girish.raos
8 Replies

7. Shell Programming and Scripting

reverse ':' separated numbers in a shell script

I want to reverse a the following: 00:11:22:33:44:55 I currently use something like below to pass it as is. But now I want the same script to reverse the above and pass it to ethtool. // psuedo code i=0 skip=0 for m in $@ do if then skip=1 ... (1 Reply)
Discussion started by: bhanu.nani
1 Replies

8. UNIX for Dummies Questions & Answers

Shell script to search for text in a file and copy file

Compete noob question.... I need a script to search through a directory and find files containing text string abcde1234 for example and then copy that file with that text string to another directory help please :eek: (9 Replies)
Discussion started by: imeadows
9 Replies

9. Shell Programming and Scripting

Unix shell script to parse the contents of comma-separated file

Dear All, I have a comma-separated file. 1. The first line of the file(header) should have 4 commas(5 fields). 2. The last line of the file should have 1 comma(2 fields). Pls help me in checking this condition in a shell script. And the number of lines between the first line and last... (11 Replies)
Discussion started by: KrishnaSaran
11 Replies

10. Shell Programming and Scripting

search for the contents in many file and print that file using shell script

hello have a file1 H87I Y788O T347U J23U and file2 J23U U887Y I99U T556U file3 I99O J99T F557J file4 N99I T666U R55Y file5 H87I T347U file6 H77U R556Y E44T file7 Y788O K98U H8I May be using script we can use file1 to search for all the files and have the output H87I file5... (3 Replies)
Discussion started by: cdfd123
3 Replies
Login or Register to Ask a Question