[Solved] Date as Input

Below is my Scenario.

I wrote one script to search the specific log files for Yesterdays date and gives the result.

I need a script like

  1. Once I run the Script, The script should ask me which date I want to search.

  2. Once i enter the date, That script should search the log files for a given date and has to gives the result.

Below is my sample script which automattically collect the Yesterdays data

grep -n processed: /var/Messages/datalogs | grep -n "$( date -d '1 day ago' +'%Y-%m-%d' )" 

Please help me in this

Sorry For my English

Like this?

#! /bin/bash
echo "Enter date: "
read date
grep -n Processed: /var/messages/datalogs | grep -n "$date"
1 Like

It worked.. Thanks:b:

IMHO, that requirement has no real value-add. The only thing that script does is, take date as input and uses it in the grep command. You could actually type the grep one-liner with required date on the command line itself.