data extract from dates


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting data extract from dates
# 1  
Old 06-04-2009
data extract from dates

I have a 1 GB file.I want to take the information for last one month from that file.

Say i want to extract data from May 1st.

File contents below.

193.135.218.124 - - [19/May/2009:01:42:09 -0700] "GET /jsp/acafai/supplier/notification.htm HTTP/1.1" 200 38531
193.135.218.124 - - [19/May/2009:01:42:09 -0700] "GET /images/2_aca_fai.gif HTTP/1.1" 200 833
193.135.218.124 - - [19/May/2009:01:42:09 -0700] "GET /jsp/acafai/supplier/arrow16.gif HTTP/1.1" 200 920
193.135.218.124 - - [19/May/2009:01:42:09 -0700] "GET /jsp/acafai/supplier/pdf.gif HTTP/1.1" 200 1691
193.135.218.124 - - [19/May/2009:01:42:09 -0700] "GET /jsp/acafai/supplier/ppt.gif HTTP/1.1" 200 189
193.135.218.124 - - [19/May/2009:01:42:09 -0700] "GET /jsp/acafai/supplier/vendorid.gif HTTP/1.1" 304 0
193.135.218.124 - - [19/May/2009:01:42:09 -0700] "GET /images/spm_secured.gif HTTP/1.1" 200 60319
193.135.218.124 - - [19/May/2009:01:42:09 -0700] "GET /jsp/acafai/supplier/word.gif HTTP/1.1" 200 193
193.135.218.124 - - [19/May/2009:01:42:09 -0700] "GET /jsp/acafai/supplier/faicontactinfo.JPG HTTP/1.1" 200 50520
193.135.218.124 - - [19/May/2009:01:42:09 -0700] "GET /jsp/acafai/supplier/editfai.JPG HTTP/1.1" 200 43789
193.135.218.124 - - [19/May/2009:01:42:10 -0700] "GET /jsp/acafai/supplier/FAI%20Attachement.jpeg HTTP/1.1" 200 26810
193.135.218.124 - - [19/May/2009:01:42:10 -0700] "GET /jsp/acafai/supplier/TotalFAISubApr2009.JPG HTTP/1.1" 200 62144
193.135.218.124 - - [19/May/2009:01:42:10 -0700] "GET /jsp/acafai/supplier/FAIbyDispApr2009.JPG HTTP/1.1" 200 61998
193.135.218.124 - - [19/May/2009:01:42:10 -0700] "GET /jsp/acafai/supplier/TotalFAISubMar2009.JPG HTTP/1.1" 200 44410
193.135.218.124 - - [19/May/2009:01:42:10 -0700] "GET /jsp/acafai/supplier/FAIbyRejApr2009.JPG HTTP/1.1" 200 48146
193.135.218.124 - - [19/May/2009:01:42:10 -0700] "GET /jsp/acafai/supplier/FAIbyRejMar2009.JPG HTTP/1.1" 200 51507
193.135.218.124 - - [19/May/2009:01:42:10 -0700] "GET /jsp/acafai/supplier/FAIbyDispFeb2009.JPG HTTP/1.1" 200 41910
# 2  
Old 06-04-2009
Have you tried grep?
# 3  
Old 06-04-2009
Hi,

Say i want report starting mar to June.

How will i grep.I can grep if i require for one month.I want collect the data for last 3 months and redirect to a file means how can i do that?
# 4  
Old 06-04-2009

Use multiple search patterns:

Code:
grep -e Mar -e Apr -e May "$file"

# 5  
Old 06-04-2009
Quote:
Originally Posted by Krrishv
...I can grep if i require for one month.I want collect the data for last 3 months and redirect to a file means how can i do that?
Also note that grep's cousin "egrep" allows you to use extended regular expressions in your search pattern. So for 3 months, you could do -

Code:
$
$ cat months.txt
Jan
Feb
Mar
Apr
May
Jun
Jul
Aug
Sep
Oct
Nov
Dec
$
$ egrep "Mar|Apr|May" months.txt
Mar
Apr
May
$
$

Search the Internet for the "grep family" of commands.

tyler_durden
# 6  
Old 06-05-2009
Quote:
Originally Posted by durden_tyler
Also note that grep's cousin "egrep" allows you to use extended regular expressions in your search pattern.

Search the Internet for the "grep family" of commands.

The "grep family" is deprecated; egrep has been replaced by grep -E, and fgrep has been replaced by grep -F.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Filtering out the data with dates

Hi, I have some data like seen below. format : apple(hhmm mm/dd).fruit apple(2345 03/25).fruit apple(2345 05/06).fruit orange(0443 05/02).fruit orange(0345 05/05).fruit orange(2134 05/04).fruit grape(0930 04/24).fruit grape(2330 03/30).fruit I need to get the data which are... (1 Reply)
Discussion started by: jayadanabalan
1 Replies

2. Shell Programming and Scripting

Display data from a range of dates

I have a data in a file called SCHED which has 5 columns: sched no, date, time, place and remarks. The image is shown below. http://dl.dropbox.com/u/54949888/Screenshot%20from%202013-01-02%2002%3A42%3A25.png Now, I want to display only the schedules which fall under a certain date range which... (2 Replies)
Discussion started by: angilulu
2 Replies

3. Shell Programming and Scripting

Fetch data between two dates from a file

Hi All, I m new to this forum & UNix too. currently i have a requirement which can fetch data from a logfile between two dates or timestamp. for example: 1. data from 2012 Jun to 2012 Jul 2. data from 2012 Jun to 2012 Jul 07 3. data from 2012 Jun 16 10:20 to 2012 Jul 03 10:10 Please... (7 Replies)
Discussion started by: KDMishra
7 Replies

4. Shell Programming and Scripting

Extract the lines between two dates

Dear experts I am new bee to scripting... Pl. help me getting the lines between two strings. I am getting the oracle sql output as below. and would like to get the time from system date compare with the date in sql output file and extract the lines. if system time is 2012-07-01 19:15:00 get... (1 Reply)
Discussion started by: nmadhuhb
1 Replies

5. UNIX for Dummies Questions & Answers

Extract dates from file name.

Hi All, I have files with names as us_Gec1_wk_01to01_2008.TXT ad_EngEnt_wk_01to10_2008.TXT br_EngMov_wk_01to10_2008.TXT Over here, I need to extract the dates and the year and store them in variables. How can I achieve the same in bash. In case of ad_EngEnt_wk_01to10_2008.TXT ... (3 Replies)
Discussion started by: Swapna173
3 Replies

6. Shell Programming and Scripting

Extract specific data content from a long list of data

My input: Data name: ABC001 Data length: 1000 Detail info Data Direction Start_time End_time Length 1 forward 10 100 90 1 forward 15 200 185 2 reverse 50 500 450 Data name: XFG110 Data length: 100 Detail info Data Direction Start_time End_time Length 1 forward 50 100 50 ... (11 Replies)
Discussion started by: patrick87
11 Replies

7. Shell Programming and Scripting

Extract data based on match against one column data from a long list data

My input file: data_5 Ali 422 2.00E-45 102/253 140/253 24 data_3 Abu 202 60.00E-45 12/23 140/23 28 data_1 Ahmad 256 7.00E-45 120/235 140/235 22 data_4 Aman 365 8.00E-45 15/65 140/65 20 data_10 Jones 869 9.00E-45 65/253 140/253 18... (12 Replies)
Discussion started by: patrick87
12 Replies

8. Shell Programming and Scripting

Extract loglines between two dates

Hi all, this is my first post, and i want to say hello to everyone in there. I've a little problem for you all :). I have a log like this: 38714 07/02/09 00:01:36 nsrd web2consolidato:D:\ done saving to pool 'SISTMSW0060' (Q09480) 32 GB 38752 07/02/09 00:01:37 nsrd /dev/rmt/STK0.2.10.5... (5 Replies)
Discussion started by: koma
5 Replies

9. Shell Programming and Scripting

extract data from a data matrix with filter criteria

Here is what old matrix look like, IDs X1 X2 Y1 Y2 10914061 -0.364613333 -0.362922333 0.001691 -0.450094667 10855062 0.845956333 0.860396667 0.014440333 1.483899333... (7 Replies)
Discussion started by: ssshen
7 Replies

10. Shell Programming and Scripting

Need script to generate all the dates in DDMMYY format between 2 dates

Hello friends, I am looking for a script or method that can display all the dates between any 2 given dates. Input: Date 1 290109 Date 2 010209 Output: 300109 310109 Please help me. Thanks. :):confused: (2 Replies)
Discussion started by: frozensmilz
2 Replies
Login or Register to Ask a Question