Sponsored Content
Full Discussion: [Solved] Date as Input
Top Forums Shell Programming and Scripting [Solved] Date as Input Post 302771576 by Padmanabhan on Thursday 21st of February 2013 04:14:22 AM
Old 02-21-2013
[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
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Get date range between 2 date input

Hi Experts, I have files name report_20090416 report_20090417 report_20090418 report_20090420 report_20090421 I have 2 input from user From Date: 20090417 To Date: 20090420 and I need to grep only those line in between. Output should be report_20090417 report_20090418... (3 Replies)
Discussion started by: tanit
3 Replies

2. UNIX for Dummies Questions & Answers

Standard error output to Pipe input - solved

Hi, I want to check a particular word is in standard error output or not. Can I acheive it in single command? For example, Delete file_name 2>error.log cat error.log Output: XXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXX Successfully deleted XXXXXXXXXXXXXXXXX where delete is... (2 Replies)
Discussion started by: poova
2 Replies

3. Shell Programming and Scripting

Append file based upon user input-- solved

Ok, I have a script with a commandline option that allows the user to add a custom function to the script file. I have tried everything in my limited knowledge of sed to get this to work and keep coming up short. I need sed to search for a line starting with a pattern, I've got that part so far,... (0 Replies)
Discussion started by: DC Slick
0 Replies

4. UNIX for Advanced & Expert Users

[SOLVED] No INPUT chain on nat table in iptables

Hello, I'm having problem with an iptables rule. It seems that on one of two systems on the nat table, the INPUT chain doesn't exist for some strange reason. I get the error below: # iptables -t nat -A INPUT -j ACCEPT iptables: No chain/target/match by that name. Here is my kernel on... (0 Replies)
Discussion started by: Narnie
0 Replies

5. UNIX for Dummies Questions & Answers

[Solved] How to refer to input file in code?

This may be a dumb question, but googling is not giving me an answer. I'm trying to figure out how to refer to an input file in my code. Lets say i run a script in bash: "sh shellscript.sh inputfile" (Inputfile will be variable...whatever file i run the script on) I wanted to make... (5 Replies)
Discussion started by: legato22
5 Replies

6. Shell Programming and Scripting

[Solved] Replace yesterday date with today's date except from the first line

Hello, I have a file like this: 2012112920121130 12345620121130msABowwiqiq 34477420121129amABamauee e7748420121130ehABeheheei in case the content of the file has the date of yesterday within the lines containing pattern AB this should be replaced by the current date. But if I use... (3 Replies)
Discussion started by: Lilu_CK
3 Replies

7. Shell Programming and Scripting

Get yesterdays Date for Input Date

Hi, I have been trying to get the yesterdays date for the Input date I pass. I know how to do for the current timestamp but how to do for the input date. Is there any way I can convert to epoch time and do manipulations and back to human readable date? Please help Thanks ... (1 Reply)
Discussion started by: abhi1988sri
1 Replies

8. Shell Programming and Scripting

[Solved] Read and validate input arguments

Hi, I need to get input arguments, as well as validate them. This is how I'm reading them: #!/bin/bash args="$@" # save arguments to variable ## Read input arguments, if so while ; do case $1 in -v | --verbose ) verbose=true;; -z | --gzip ) compression="gz";; ... (3 Replies)
Discussion started by: AlbertGM
3 Replies

9. Shell Programming and Scripting

[Solved] Testing Data Type of User Input

hi all i'm new in shell scripting and now i'm working on project and i wanna make a function take input from user and test it's datatype then if correct write it to file i wounder what is the best way to do this ? can i use awk ? edit by bakunin: Please give your threads a meaningful... (5 Replies)
Discussion started by: mohamed91
5 Replies

10. Shell Programming and Scripting

Script to get previous date for the given input date..

hi all, need a script or command to get the previous date for the given input date... like in my script i will pass date as input parameter like 2014-12-01 and i want the output as previous date.. ie.. 2014-11-30 (2 Replies)
Discussion started by: hemanthsaikumar
2 Replies
SCRIPT(1)						    BSD General Commands Manual 						 SCRIPT(1)

NAME
script -- make typescript of terminal session SYNOPSIS
script [-a] [-f] [-q] [-t] [file] DESCRIPTION
Script makes a typescript of everything printed on your terminal. It is useful for students who need a hardcopy record of an interactive session as proof of an assignment, as the typescript file can be printed out later with lpr(1). If the argument file is given, script saves all dialogue in file. If no file name is given, the typescript is saved in the file typescript. Options: -a Append the output to file or typescript, retaining the prior contents. -f Flush output after each write. This is nice for telecooperation: One person does `mkfifo foo; script -f foo' and another can super- vise real-time what is being done using `cat foo'. -q Be quiet. -t Output timeing data to standard error. This data contains two fields, separated by a space. The first field indicates how much time elapsed since the previous output. The second field indicates how many characters were output this time. This information can be used to replay typescripts with realistic typing and output delays. The script ends when the forked shell exits (a control-D to exit the Bourne shell (sh(1)), and exit, logout or control-d (if ignoreeof is not set) for the C-shell, csh(1)). Certain interactive commands, such as vi(1), create garbage in the typescript file. Script works best with commands that do not manipulate the screen, the results are meant to emulate a hardcopy terminal. ENVIRONMENT
The following environment variable is utilized by script: SHELL If the variable SHELL exists, the shell forked by script will be that shell. If SHELL is not set, the Bourne shell is assumed. (Most shells set this variable automatically). SEE ALSO
csh(1) (for the history mechanism), replay(1). HISTORY
The script command appeared in 3.0BSD. BUGS
Script places everything in the log file, including linefeeds and backspaces. This is not what the naive user expects. Linux July 30, 2000 Linux
All times are GMT -4. The time now is 06:47 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy