I’m working with a log file and I want to print from a specific day till the end of it . that specific date is ($sd=27/Dec/2002) for example. now I want to search for this day and print from it till the end of log file ! but what if 27/Dec is not among items in log file ? it should search for items >= $sd (27/Dec) , how could I do this?
this code just search for $Sd which is 27/Dec/2002 , I want to search for items >= $sd
sed -n "$(awk '/'$sd'/ {print NR}' serverlog.log.log | head -1),$ p" serveerlog.log|cut -d: -f1
example of log file :
213.64.237.213 - - [23/Dec/2002:03:02:22 +0100]
213.132.36.66 - - [28/Dec/2002:19:33:29 +0100]
and the log file is sorted !
it would be very easy with awk. see the example below:
output
update
try this awk line: $sd is the variable. hope that it would work for you.