The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #5 (permalink)  
Old 04-20-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
You might think wrong. Try it.

Like I already wrote, this is equivalent to grep date file

For example, grep 2008-04-20 traffic/127.0.0.1 would search for 2008-04-20 in the file traffic/127.0.0.1.

Maybe your logs use a different date format, but you get the idea.

PS. Simpler still awk script, provided your date format doesn't have slashes in it:


Code:
#!/bin/sh

case $# in 0|1) echo "syntax: $0 date files ..." >&2; exit 2;; esac

date=$1
shift

awk "/$date/" "$@"


Last edited by era; 04-20-2008 at 03:45 PM.. Reason: Clarifying (?) .... grep .... example ....