Grepping the data between 2 date ranges


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Grepping the data between 2 date ranges
# 1  
Old 03-14-2018
RedHat Grepping the data between 2 date ranges

Hi There, Good Day !!

I have txt file containing data in the below format. There are many lines, here i have mentioned for example.

Code:
cat remo.txt

2/3/2017  file1
3/4/2016  file2
6/6/2015  file5
1/1/2018  file3
4/3/2014  file4
-
-
-

I need to grep the file names for given date rage from user.

for example --

if user enters any date rages (start date) and (end date) as arguments along with script like below

Code:
./script.sh 1/1/2014 1/1/2016

then output will be
Code:
4/3/2014  file4
3/4/2016  file2
6/6/2015  file5


Please guide me for this portion of script, i will complete my task.

Thanks in Advance.


Moderator's Comments:
Mod Comment Please use CODE tags as required by forum rules!

Last edited by RudiC; 03-14-2018 at 05:46 AM.. Reason: Added CODE tags.
# 2  
Old 03-14-2018
Why is 3/4/2016 file2 in the results when end date is 1/1/2016? And, is the date format mm/dd/yyyy or dd/mm/yyyy?
# 3  
Old 03-14-2018
date format is dd/mm/yy.

Moderator's Comments:
Mod Comment Thanks for trying code tags, but overdoing doesn't help either. Tags for code and data, not for normal text.

Last edited by RudiC; 03-14-2018 at 06:01 AM.. Reason: Corrected code tag placement.
# 4  
Old 03-14-2018
And the other question?

Plus, on top: Any attempts / ideas / thoughts from your side?
# 5  
Old 03-14-2018
Actually, i tried to do with convert dates in unix time and compare, but it does not work.

so i am seeking help from this forum.
# 6  
Old 03-14-2018
And the residual question?
# 7  
Old 03-14-2018
Apart form this code, i have to do some more code on the data which script will get between start date and end date. Please help me with the above code, the rest i can finish.

Thanks
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Search files between date ranges - Ctime usage

Hello, I am a noob and need some help. I am trying to find files created between a date range. For Example: These are files in directory. -rw-r--r-- 1 user staff 6 May 8 09:43 file1.txt -rw-r--r-- 1 user staff 6 May 8 09:43 file2.txt -rw-r--r-- 1 user... (8 Replies)
Discussion started by: r@v!7*7@
8 Replies

2. Programming

Derivation of values falling on date ranges

Hi Guys, I am having below tables used in oracle bal ID BALANCE BAL_DATE 1 -11.71 01-JAN-05 00.00.00 1 -405.71 02-JAN-05 00.00.00 1 -760.71 03-JAN-05 00.00.00 ref_table PRODUCT EFF_FROM_DATE EFF_TO_DATE TYPE MIN_AMT MAX_AMT CHARGE 12 01-JAN-05 00.00.00 01-JAN-06... (6 Replies)
Discussion started by: rohit_shinez
6 Replies

3. Shell Programming and Scripting

Grepping data using awk

Hello, I have a data in file 1 2000000024776 2000000026979 2000000033355 2000000036309 2000000041291 2000000042679 2000000067221 and in file 2 its like this 2000000024776 16 2000000026979 16 2000000033355 16 (2 Replies)
Discussion started by: mirwasim
2 Replies

4. Shell Programming and Scripting

Help with grepping data from a text file

Hello, I have a text file which contains a list of strings which I want to grep from another file where these strings occur and print out only these lines. I had earlier used the grep command where File1 was the file containing the strings to be grepped (Source File) and File2 the Target File... (4 Replies)
Discussion started by: gimley
4 Replies

5. Shell Programming and Scripting

getting files between specific date ranges in solaris

hi ! how can i get files in a directory between certain date ranges ? say all files created/modified between Jan24 - Jan31 thanks (10 Replies)
Discussion started by: aliyesami
10 Replies

6. Shell Programming and Scripting

Grepping Date Variable

Hello, I would like for the user to input the date for a particular log file, then have the input sent to a variable, which is then used via grep to extra the logs for the specific date the user request. I did some searching, but I still don't understand why I'm not seeing any result. ... (4 Replies)
Discussion started by: ravzter
4 Replies

7. Linux

search on weblogic logs with date time ranges

Hi All, The developers want me to search and capture the weblogic log, you know this big logs of htmls. They want to me to have ranges on the date and time. Like from "2010-01-20 14:04:46,186" to "2010-01-20 15:00:12,490" I can only do this, cat /usr/local/bea/logs_prod1/debug.log... (1 Reply)
Discussion started by: itik
1 Replies

8. Shell Programming and Scripting

search on weblogic logs with date time ranges 2

Hi All, The developers want me to search and capture the weblogic log, you know this big logs of htmls. They want to me to have ranges on the date and time. Like from "2010-01-20 14:04:46,186" to "2010-01-20 15:00:12,490" I can only do this, cat /usr/local/bea/logs_prod1/debug.log |... (1 Reply)
Discussion started by: itik
1 Replies

9. Shell Programming and Scripting

date ranges

Hi, Please anyone help to achive this using perl or unix scripting . This is date in my table 20090224,based on the date need to check the files,If file exist for that date then increment by 1 for that date and check till max date 'i.e.20090301 and push those files . files1_20090224... (2 Replies)
Discussion started by: akil
2 Replies

10. Shell Programming and Scripting

find command: various date ranges

Hi, I have writtena script that will recursivly go into subdirecotries and report out what files there are in there that have not been accessed over various date ranges. I do this using a number of find commands: find . -path './.snapshot' -prune -o -type f -atime -8 find... (4 Replies)
Discussion started by: littleIdiot
4 Replies
Login or Register to Ask a Question