repetative grep from user specified start file...

Hi,

Thanks for reading...

The filenames I need to grep start as zcat 20000101*, this obviously being the 1st of Jan this year, and need to grep to present day, for a user defined string, much like UKLIrad055232. This is the exact format, four letters caps, three small, six numbers.

~SUMMARY~

I need the grep to be automated, from user input of string to search for (which I assume is simply $1), from the 1st of Jan (ie zcat 20000101*) to present day (today being the 14th, would be zcat 20000114*), without entering finish date.

I'm using Sun OS 5.5.1, and use VI as my editor program, and will give 300 points for a working solution!!!

Thanks for your time...appreciate it very much...

Tricky.
TrickyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

TrickyAuthor Commented:
Please mail lafarge4@hotmail.com
(other address is dead)...

Thx!

Tricky.
0
maxkirCommented:
If u have perl:

try command
perl grep.pl UKLIrad055232

------- file grep.pl --------------
#!/usr/local/bin/perl

($sec,$min,$hour,$mday,$mon,$year) = localtime(time);

$mon ++;
$year += 1900;
$last = sprintf("$year%02d%02d", $mon, $mday);

for ($i = 20000101; $i< $last; $i++)
{
    system("zcat $i* |grep $ARGV[1]");
}
---------------------------------------
0
TrickyAuthor Commented:
Hi Maxkir :)

I need a seamless, complete, solution.

I need the grep string to be defined upon user input.

I understand unix, but am not fluent...in fact I know very little...

All I need to use is UNIX itself, nothing else...

Talk soon...THX..

Tricky
0
C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

ozoCommented:
In what way is maxkir's solution not seamless or complete enough for you?
0
ozoCommented:
If you don't have perl:

#!/bin/sh
end=`date +%Y%m%d`
end=`expr $end + 1`
echo $end
for i in `ls 2000[01][0-9][0-9][0-9]*`
do
if expr $end \<= $i~ >/dev/null ; then break; fi
zcat $i | grep $1
done
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ecwCommented:
#!/bin/sh
end=`date +%Y%m%d`
ls -1 2000[01][0-9][0-9][0-9]* | sed "/^$end/q" | xargs zcat | grep -e "$1"
0
TrickyAuthor Commented:
Thanks ozo... this is exactly what was required. A UNIX script, that did exactly what I asked...perfect.

Kind Regards,

Tricky.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.