Sponsored Content
Top Forums Shell Programming and Scripting Grep search for value between dates Post 302737199 by Corona688 on Wednesday 28th of November 2012 12:58:24 PM
Old 11-28-2012
grep does not understand dates, it is not a programming language. awk is a programming language, and better suited.

You are lucky, the dates are in YYYY-MM-DD order, which is directly sortable and comparable with > < string comparisons.

We probably need to see more of the XML.

Last edited by Corona688; 11-28-2012 at 02:06 PM..
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

grep a log file between 2 dates

Hi Currently I can grep a log file with the following command: $results = `grep -A 2 '^$date.$time.*' $log`; and the following arguments: $date = 2007/04/25 $time = 16:07 Log example: 2007/04/25 16:07:12.145701 2007/05/25 14:07:12.145701 2007/05/25 17:07:12.145701 2007/06/25... (37 Replies)
Discussion started by: Epiphone
37 Replies

2. Shell Programming and Scripting

grep a log file to filter previous dates

Hi, I have problem of filtering a log file from my perl script. #cat /data/pinpe.csv_20070731 | nawk -v FS=, '{print $1','$18','$22','$26}' | grep -w 100 | grep -w 1 | nawk '{print $4}' Below is the output: 2009-06-16 2009-01-29 2009-06-02 2008-03-05 2007-08-05 2007-09-24... (5 Replies)
Discussion started by: pinpe
5 Replies

3. UNIX for Dummies Questions & Answers

How do I search between dates?

I have a folder that has files that go way back to 2005. How can I search for files between say Jan 2006 - Dec 2007 only? I did a man on the Find command but nothing in there. Any help would be appreciated. (4 Replies)
Discussion started by: bbbngowc
4 Replies

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

5. Shell Programming and Scripting

Script to search specific folders dates /mm/dd/ structure

Hi, I have a script that handles a huge amount of log files from many machines and copies it into a SAN location with the following directory structure: /SAN/machinenames/yyyy/m/d so for example /SAN/hosta/2011/3/12/files* Now I am writing a bash script to search for files between to date... (4 Replies)
Discussion started by: GermanJulian
4 Replies

6. Shell Programming and Scripting

Search pattern on logfile and search for day/dates and skip duplicate lines if any

Hi, I've written a script to search for an Oracle ORA- error on a log file, print that line and the .trc file associated with it as well as the dateline of when I assumed the error occured. In most it is the first dateline previous to the error. Unfortunately, this is not a fool proof script.... (2 Replies)
Discussion started by: newbie_01
2 Replies

7. Programming

MYSQL query search between dates

Just a little help if possible I have a table with date data, I want to select dates that fall between today and 1 month ago, here's my query SELECT id, stdate, DATE_SUB(CURDATE(), INTERVAL 1 month) as monthago, CURDATE() as today FROM data_table where (stdate between 'today' and 'monthago')... (4 Replies)
Discussion started by: barrydocks
4 Replies

8. What is on Your Mind?

Grep file containing dates

How to grep a file containing dates to only last 30 days then move to another folder (7 Replies)
Discussion started by: kmarcus
7 Replies

9. UNIX for Beginners Questions & Answers

How to use a grep search to search for a specific string within multiple directories?

Lets say I have a massive directory which is filled with other directories all filled with different c++ scripts and I want a listing of all the scripts that contain the string: "this string". Is there a way to use a grep search for that? I tried: grep -lr "this string" * but I do not... (3 Replies)
Discussion started by: Circuits
3 Replies
PREG_SPLIT(3)								 1							     PREG_SPLIT(3)

preg_split - Split string by a regular expression

SYNOPSIS
array preg_split (string $pattern, string $subject, [int $limit = -1], [int $flags]) DESCRIPTION
Split the given string by a regular expression. PARAMETERS
o $pattern - The pattern to search for, as a string. o $subject - The input string. o $limit - If specified, then only substrings up to $limit are returned with the rest of the string being placed in the last substring. A $limit of -1, 0 or NULL means "no limit" and, as is standard across PHP, you can use NULL to skip to the $flags parameter. o $flags -$flags can be any combination of the following flags (combined with the | bitwise operator): o PREG_SPLIT_NO_EMPTY - If this flag is set, only non-empty pieces will be returned by preg_split(3). o PREG_SPLIT_DELIM_CAPTURE - If this flag is set, parenthesized expression in the delimiter pattern will be captured and returned as well. o PREG_SPLIT_OFFSET_CAPTURE - If this flag is set, for every occurring match the appendant string offset will also be returned. Note that this changes the return value in an array where every element is an array consisting of the matched string at offset 0 and its string offset into $subject at offset 1. RETURN VALUES
Returns an array containing substrings of $subject split along boundaries matched by $pattern. EXAMPLES
Example #1 preg_split(3) example : Get the parts of a search string <?php // split the phrase by any number of commas or space characters, // which include " ", , , and f $keywords = preg_split("/[s,]+/", "hypertext language, programming"); print_r($keywords); ?> The above example will output: Array ( [0] => hypertext [1] => language [2] => programming ) Example #2 Splitting a string into component characters <?php $str = 'string'; $chars = preg_split('//', $str, -1, PREG_SPLIT_NO_EMPTY); print_r($chars); ?> The above example will output: Array ( [0] => s [1] => t [2] => r [3] => i [4] => n [5] => g ) Example #3 Splitting a string into matches and their offsets <?php $str = 'hypertext language programming'; $chars = preg_split('/ /', $str, -1, PREG_SPLIT_OFFSET_CAPTURE); print_r($chars); ?> The above example will output: Array ( [0] => Array ( [0] => hypertext [1] => 0 ) [1] => Array ( [0] => language [1] => 10 ) [2] => Array ( [0] => programming [1] => 19 ) ) NOTES
Tip If you don't need the power of regular expressions, you can choose faster (albeit simpler) alternatives like explode(3) or str_split(3). Tip If matching fails, an array with a single element containing the input string will be returned. SEE ALSO
PCRE Patterns, preg_quote(3), implode(3), preg_match(3), preg_match_all(3), preg_replace(3), preg_last_error(3). PHP Documentation Group PREG_SPLIT(3)
All times are GMT -4. The time now is 01:01 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy