Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help in scripting

Status
Not open for further replies.

nitincm

Technical User
Sep 10, 2003
22
US
If file is created after April25 then find "xyz" pattern in that file.
then if xyz pattern found then send it to me by email.

how do I write the script for this?

thanks in advance.
 
man touch
man find
man grep
man sendmail

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Good catch p5wizard, forgot the attachment ...
 
Thanks,
Yes I can able to find and grep...
find . -name "error_log*" -exec grep -il "xyz" {} \;
Output is coming....
now I would like to find "xyz" in file only which is created after 25 April.

 
Again:
man touch
man find (hint: the -newer primary)

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
(hint: the -newer primary) ?
newer is compare with old file but here need to find file which is created after 25 April...

how I can do it?
 
man touch

newer is compare with old file but here need to find file which is created after 25 April.

[tt]touch MMDDhhmm file_dated

find /path -newer file_dated
[/tt]

man touch
man find
 
can you give me the syntax?

find . -name "web_log*" -exec grep -il "xyz" {} \;

how I can use -newer in above cmd?
 
touch 04250000 /tmp/april25
find . -name "web_log*" -newer /tmp/april25 -exec grep -il "xyz" {} \;
rm /tmp/april25

file must be named web_log* and must be newer than the created (empty) file /tmp/april25 which gets a modtime of april 25th 00:00h

HTH,

p5wizard
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top