|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
[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 Code:
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 |
| Sponsored Links | ||
|
|
#2
|
||||
|
||||
|
Like this? Code:
#! /bin/bash echo "Enter date: " read date grep -n Processed: /var/messages/datalogs | grep -n "$date" |
| The Following User Says Thank You to balajesuri For This Useful Post: | ||
Padmanabhan (02-21-2013) | ||
| Sponsored Links | ||
|
|
#3
|
|||
|
|||
|
It worked.. Thanks
|
|
#4
|
||||
|
||||
|
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.
|
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| [Solved] Replace yesterday date with today's date except from the first line | Lilu_CK | Shell Programming and Scripting | 3 | 12-03-2012 01:44 PM |
| [Solved] How to refer to input file in code? | legato22 | UNIX for Dummies Questions & Answers | 5 | 11-14-2012 03:03 PM |
| [SOLVED] No INPUT chain on nat table in iptables | Narnie | UNIX for Advanced & Expert Users | 0 | 11-03-2011 04:20 PM |
| Append file based upon user input-- solved | DC Slick | Shell Programming and Scripting | 0 | 02-16-2011 06:07 AM |
| Standard error output to Pipe input - solved | poova | UNIX for Dummies Questions & Answers | 2 | 02-22-2010 12:56 AM |
|
|