Sponsored Content
Full Discussion: Creating searches?
Top Forums Shell Programming and Scripting Creating searches? Post 302194404 by Smiling Dragon on Monday 12th of May 2008 09:41:39 PM
Old 05-12-2008
I'd suggest working with perl for this as it's rather good at parsing files and creating nicely formatted reports.

Here's some pseudo-code to help get you going:
Code:
#!/usr/local/bin/do-what-i-want-not-what-i-write
print "Start date to search from: "
read from STDIN to $datestart
print "End date to search up until: "
read from STDIN to $dateend
print "File to search on: "
read from STDIN to $file

$hitcount=0
new array($iplist)

while (read $line from $file) {
  split $line into ($ip,$date)
  if ($date >= $datestart && $date <= $dateend) {
    $iplist[$ip]++
    $hitcount++
  }
}
$hitcount_unique=arraysize($iplist)
print_pretty_report($hitcount,$hitcount_unique)

 

8 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

grep: do multiple searches?

I want to search the file /etc/passwd for all lines containing 'csh' but exlude all those lines that have '/usr' in them and dump the results into the file result. IMPORTANT: I need to do this in one command line. The following does not work: grep -v \(\/usr\) \(csh\) /etc/passwd >... (4 Replies)
Discussion started by: sdemba
4 Replies

2. News, Links, Events and Announcements

New Tool Searches and Replaces SCO Code

See this article: http://story.news.yahoo.com/news?tmpl=story&cid=74&ncid=738&e=9&u=/cmp/20030809/tc_cmp/13000487 (3 Replies)
Discussion started by: Neo
3 Replies

3. Shell Programming and Scripting

Perl syntax for sed searches

I am aware that Perl has a lot of features that originally came from sed and awk. I have a pattern that I am using like this: sed -n '/|Y|/p' I want to do the same thing in Perl and be able to either save that value in some kind of variable or array or potentially write it out to a file. ... (11 Replies)
Discussion started by: masinick
11 Replies

4. UNIX and Linux Applications

Alpine: LDAP searches hang

I just configured my ldap server in Alpine, but every search hangs indefinitely (or so it seems) and I have to end up killing Alpine and starting back up. The LDAP server runs over SSL on port 636, so I have specified port 636, but there doesn't seem to be an SSL option available so I turned on... (0 Replies)
Discussion started by: retrovertigo
0 Replies

5. Shell Programming and Scripting

Can someone please help me optimize my code (script searches subdirectories)?

Here is my code. What it does is it reads an input file (input.txt which contains roughly 2,000 search phrases) and searches a directory for files that contains the search phrase. The directory contains roughly 1900 files and 84 subdirectories. The output is a file (output.txt) that shows only the... (23 Replies)
Discussion started by: jl487
23 Replies

6. Shell Programming and Scripting

Need help in awk for multiple searches

I have a below file RCS File name : abc.txt something something .... symbolic names: implemented : 1.1 ssssssumthing Revision 1.2 date : 12/12/12 author : abc Revision 1.1 date : 11/11/11 author xyz So now , in this file i have to first look for the implemented... (1 Reply)
Discussion started by: ashishagg2005
1 Replies

7. UNIX for Dummies Questions & Answers

Output based on multiple searches

I have a file that looks like this: >Sample 539 GCCCAGCGCGCGILTGCCGCCGTCTCCGCCTGTCJOHNCCGCCATTGCCCCCGGTTAC I am using the following code to search specific patterns: awk '/^>/ { print $0 } NR==2 {if (/GIL/) { print "\t" "1" } else { print "\t" "0" }} NR==2 {if (/JOHN/) { print "\t""\t"... (7 Replies)
Discussion started by: Xterra
7 Replies

8. Shell Programming and Scripting

Customized text searches by using grep

I tried to ease text searches so made a customized grep: g () { if then i= for s in $2 do i="$i --include=*.$s" done else i='--include=*.txt --include=*.ini --include=*.*sh --include=*.c* --include=*.h --include=*.js --include=*.reg' fi grep -P -e \'$1\' -r "$i" } but I... (3 Replies)
Discussion started by: abdulbadii
3 Replies
NetSDS::Util::DateTime(3pm)				User Contributed Perl Documentation			       NetSDS::Util::DateTime(3pm)

NAME
NetSDS::Util::DateTime - common date/time processing routines SYNOPSIS
use NetSDS::Util::DateTime; print "Current date: " . date_now(); DESCRIPTION
This package provides set of routines for date and time processing. EXPORTED FUNCTIONS
date_now_array([TIME]) Returns array of date items for given date. If source date is not set current date used. date_now([TIME]) Return [given] date as string. 2001-12-23 14:39:53 date_now_iso8601([TIME]) Return date as ISO 8601 string. 20011223T14:39:53Z <http://en.wikipedia.org/wiki/ISO_8601> http://www.w3.org/TR/NOTE-datetime <http://www.w3.org/TR/NOTE-datetime> date_strip(DATE) Trim miliseconds from date. date_date(DATE) Trim time part from date. date_time(DATE) Trim date part from date. time_from_string($string) Return parsed date/time structure. date_from_string($string) Return date from string representation. date_inc([INCREMENT, [TIME]]) Return date incremented with given number of seconds. date_inc_string([INCREMENT, [TIME]]) Return string representation of date incremented with given number of seconds. EXAMPLES
None yet BUGS
Unknown yet SEE ALSO
Date::Parse, Date::Format TODO
Import stuff from Wono project AUTHOR
Valentyn Solomko <val@pere.org.ua> Michael Bochkaryov <misha@rattler.kiev.ua> perl v5.12.4 2011-08-27 NetSDS::Util::DateTime(3pm)
All times are GMT -4. The time now is 10:40 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy