Sponsored Content
Top Forums Shell Programming and Scripting Get date range between 2 date input Post 302309236 by reddybs on Tuesday 21st of April 2009 11:17:26 AM
Old 04-21-2009
Quote:
Originally Posted by tanit
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
report_20090420

Thanks,

Try this,
Variables i1 and i2 are inputs
Code:
$ echo $i1
20090417
 
$ echo $i2
20090420
 
$ cat file
report_20090416
report_20090417
report_20090418
report_20090420
report_20090421
 
$ awk -F"_" ' $2 >= '$i1' && $2 <= '$i2' {print}' file
report_20090417
report_20090418
report_20090420

 

10 More Discussions You Might Find Interesting

1. UNIX Desktop Questions & Answers

date range

I have a number of instances wher I need to run reports for the previous month and need to include the last months date range in the sql. I want to create a string which consists of the first and last dates of last month separated with an ' and ' ie for this month (Feb) I want it to say '01/01/10... (3 Replies)
Discussion started by: Niven
3 Replies

2. Shell Programming and Scripting

Search on date range of file based on user input

Hello I would like to ask for help with a script to search a directory that contains many log files and based on a users input after being prompted, they enter a date range down to the hour which searches the files that contain that range. I dont know how to go about this. I am hoping that the... (5 Replies)
Discussion started by: lostincashe
5 Replies

3. Shell Programming and Scripting

display Range of date depend on user input php

Hi, i am very new to php Is it possible to display Range of date depend on user input day example: user input 2 day start from 28/4/12 it will add 2 day from date of input so display should look like this 28/4/12 to 30/4/12 then from 30/412 user add another 4 date so will... (0 Replies)
Discussion started by: guidely
0 Replies

4. Shell Programming and Scripting

Converting a date to friday date and finding Min/Max date

Dear all, I have 2 questions. I have a file with many rows which has date of the format YYYYMMDD. 1. I need to change the date to that weeks friday date(Ex: 20120716(monday) to 20120720). Satuday/Sunday has to be changed to next week friday date too. 2. After converting the date to... (10 Replies)
Discussion started by: 2001.arun
10 Replies

5. UNIX for Advanced & Expert Users

Help with ksh script to list, then cp files from a user input date range

Hi, I'm quite new to ksh scripting, can someone help me with this. Requirements: I need to create a script that list the files from a user input date range. e. g. format of file: *c1*log.2012-12-22-14-00* *c1*log.2012-12-22-14-00* *c1*log.2012-12-22-14-00*... (1 Reply)
Discussion started by: chococrunch6
1 Replies

6. 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

7. Shell Programming and Scripting

Date listing in a date range

Solaris 10 ksh88 Sorry for re-hashing some of this, but I can't find a proper solution in the forums. Starting with /a/archive containing (on and on date formatted directories) 20060313 20080518 20100725 20121015 20060314 20080519 ... (1 Reply)
Discussion started by: moesplace
1 Replies

8. 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

9. UNIX for Dummies Questions & Answers

Find the count of files by last created date based on the given date range

My unix version is IBM AIX Version 6.1 I tried google my requirement and found the below answer, find . -newermt “2012-06-15 08:13" ! -newermt “2012-06-15 18:20" But newer command is not working in AIX version 6.1 unix I have given my requirement below: Input: atr files: ... (1 Reply)
Discussion started by: yuvaa27
1 Replies

10. Shell Programming and Scripting

Date range

Dear all, how can I select in the file below only the files created between Aug 14 2014 and Feb 03 2015? EZA2284I -rw-r--r-- 1 30 8 356954 Aug 15 2014 file1 EZA2284I -rw-rw-r-- 1 30 8 251396 Feb 05 12:53 file2 EZA2284I -rw-rw-r-- 1 30 8 ... (3 Replies)
Discussion started by: simomuc
3 Replies
args(1) 							   GNU Telephony							   args(1)

NAME
args - manipulate and output command arguments. SYNOPSIS
args [options] args... DESCRIPTION
This command is used to manipulate and echo command line arguments to standard out. This can include adding quotes around each argument passed or a separator, or to output each argument on a separate line. The program source also offers a basic example of how to use shell argument parsing and localization in ucommon. OPTIONS
--delim=char Set a deliminator character, such as ',', to use between each argument when outputing arguments. --directory If argument is a directory, list directory contents as arguments. --follow If argument is a directory and a symlink, follow symlinks recursively. --lines Output each argument on a separate line. --quote=char|pair Set a quote or special leading and trailing pair of characters to surround each argument with when output. A typical use might be --quote=() to surround arguments in parenthesis. --recursive If argument is a directory, recursively scan directory and any subdirectory contents as arguments. --reverse Reverse order of arguments. --help Outputs help screen for the user. AUTHOR
args was written by David Sugar <dyfet@gnutelephony.org>. REPORTING BUGS
Report bugs to bug-commoncpp@gnu.org. COPYRIGHT
Copyright (C) 2009 David Sugar, Tycho Softworks. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICU- LAR PURPOSE. GNU uCommon January 2010 args(1)
All times are GMT -4. The time now is 09:12 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy