To print lines between 2 timestamps using awk|sed and regex
Hi,
I am using the following code to fetch lines that are generated in last 1 hr . Hence, I am using date function to calculate -last 1 hr & the current hr and then somehow use awk (or sed-if someone could guide me better)
with some regex pattern.
The above code doesnot give any errors and I have also tried without $0~
Let's say I want all the lines starting from
Apr 07, 2013 1:mm:ss AM
to
Apr 07, 2013 2:mm:ss AM
if script gets executed b/w 2:00-2:59 hrs
OR
lines between
Apr 07, 2013 12:mm:ss PM
to
Apr 07, 2013 1:mm:ss PM
if script gets executed b/w 13:00-13:59 hrs
I have been searching for similar posts reported by various users, but I can only see variables being used in awk, without any regex pattern.
Hi folks,
Lets say I have the following text file:
name, lastname, 1234, name.lastname@test.com
name1, lastname1, name2.lastname2@test.com, 2345
name, 3456, lastname, name3.lastname3@test.com
4567, name, lastname, name4.lastname4@test.com
I now need the following output:
1234... (5 Replies)
Hello,
I need to print four lines inmediatly after the regexp, but not the line containing the regexp. The print should show the four lines together in one.
Thanks! (13 Replies)
Hi,
I need a help to search a pattern and print the multiple lines between them.
Input file:
Tue May 29 12:30:33 EDT 2012:threadWebContainer : 357:com.travimp.hotelierlinks.abba.service.RequestHandler.requestService(String, ITICSDataSet): hotelCancelReservation request: ... (4 Replies)
Hello,
I can extract lines in a file, between two strings but only one time.
If there are multiple occurencies, my command show only one block.
Example, monfichier.txt contains :
debut_sect
texte L1
texte L2
texte L3
texte L4
fin_sect
donnees inutiles 1
donnees inutiles 2
... (8 Replies)
Hello,
I need an awk command to print only the lines that match regex on xth field from file.
For example if I use this command
awk -F"|" ' $22 == "20130117090000.*" 'It wont work, I think, because single quotes wont allow the usage of the metacharacter star * . On the other hand I dont know... (2 Replies)
grep -v will exclude matching lines, but I want something that will print all lines but exclude a matching field. The pattern that I want excluded is '/mnt/svn'
If there is a better solution than awk I am happy to hear about it, but I would like to see this done in awk as well. I know I can... (11 Replies)
I have a line that I need to parse through and extract a pattern that occurs multiple times in it.
Example line:
getInfoCall: info received please proceed, getInfoCall: info received please proceed, getInfoCall: info received please proceed, getInfoCall: info received please proceed,... (4 Replies)
Hello.
I have been looking high and low for the solution for this. I seems there should be a simple answer, but alas.
I have a big xml file, and I need to extract certain information from specific items. The information I need can be found between a specific set of tags. let's call them... (2 Replies)
Hi Guys
I am looking for a solution to one problem to remove parentheses in a range of lines.
Input file
module bist_logic_inst(a, ab , dhd, dhdh , djdj, hdh, djjd, jdj, dhd, dhp, dk
);
input a;
input ab;
input dhd;
input djdj;
input dhd;
output hdh;
output djjd;
output jdj;... (5 Replies)
Discussion started by: kshitij
5 Replies
LEARN ABOUT PHP
datefmt_format_object
DATEFMT_FORMAT_OBJECT(3) 1 DATEFMT_FORMAT_OBJECT(3)IntlDateFormatter::formatObject - Formats an object
Object oriented style
SYNOPSIS
publicstatic string IntlDateFormatter::formatObject (object $object, [mixed $format = NULL], [string $locale = NULL])
DESCRIPTION
Procedural style string datefmt_format_object (object $object, [mixed $format = NULL], [string $locale = NULL])
This function allows formatting an IntlCalendar or DateTime object without first explicitly creating a IntlDateFormatter object.
The temporary IntlDateFormatter that will be created will take the timezone from the passed in object. The timezone database bundled with
PHP will not be used - ICU's will be used instead. The timezone identifier used in DateTime objects must therefore also exist in ICU's
database.
PARAMETERS
o $object
- An object of type IntlCalendar or DateTime. The timezone information in the object will be used.
o $format
- How to format the date/time. This can either be an array with two elements (first the date style, then the time style, these
being one of the constants IntlDateFormatter::NONE, IntlDateFormatter::SHORT, IntlDateFormatter::MEDIUM, IntlDateFormatter::LONG,
IntlDateFormatter::FULL), a long with the value of one of these constants (in which case it will be used both for the time and the
date) or a string with the format described in the ICU documentation. If NULL, the default style will be used.
o $locale
- The locale to use, or NULL to use the default one.
RETURN VALUES
A string with result or FALSE on failure.
EXAMPLES
Example #1
datefmt_format_object(3) examples
<?php
/* default timezone is irrelevant; timezone taken from the object */
ini_set('date.timezone', 'UTC');
/* default locale is taken from this ini setting */
ini_set('intl.default_locale', 'fr_FR');
$cal = IntlCalendar::fromDateTime("2013-06-06 17:05:06 Europe/Dublin");
echo "default:
",
IntlDateFormatter::formatObject($cal),
"
";
echo "long $format (full):
",
IntlDateFormatter::formatObject($cal, IntlDateFormatter::FULL),
"
";
echo "array $format (none, full):
",
IntlDateFormatter::formatObject($cal, array(
IntlDateFormatter::NONE,
IntlDateFormatter::FULL)),
"
";
echo "string $format (d 'of' MMMM y):
",
IntlDateFormatter::formatObject($cal, "d 'of' MMMM y", 'en_US'),
"
";
echo "with DateTime:
",
IntlDateFormatter::formatObject(
new DateTime("2013-09-09 09:09:09 Europe/Madrid"),
IntlDateFormatter::FULL,
'es_ES'),
"
";
The above example will output:
default:
6 juin 2013 17:05:06
long $format (full):
jeudi 6 juin 2013 17:05:06 heure d'ete irlandaise
array $format (none, full):
17:05:06 heure d'ete irlandaise
string $format (d 'of' MMMM y):
6 of June 2013
with DateTime:
lunes, 9 de septiembre de 2013 09:09:09 Hora de verano de Europa central
PHP Documentation Group DATEFMT_FORMAT_OBJECT(3)