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
date_default_timezone_get
DATE_DEFAULT_TIMEZONE_GET(3) 1 DATE_DEFAULT_TIMEZONE_GET(3)date_default_timezone_get - Gets the default timezone used by all date/time functions in a script
SYNOPSIS
string date_default_timezone_get (void )
DESCRIPTION
In order of preference, this function returns the default timezone by:
o Reading the timezone set using the date_default_timezone_set(3) function (if any)
o Prior to PHP 5.4.0
only: Reading the $TZ environment variable (if non empty)
o Reading the value of the date.timezone ini option (if set)
o Prior to PHP 5.4.0
only: Querying the host operating system (if supported and allowed by the OS). This uses an algorithm that has to guess the time-
zone. This is by no means going to work correctly for every situation. A warning is shown when this stage is reached. Do not rely
on it to be guessed correctly, and set date.timezone to the correct timezone instead.
If none of the above succeed, date_default_timezone_get will return a default timezone of UTC.
RETURN VALUES
Returns a string.
CHANGELOG
+--------+---------------------------------------------------+
|Version | |
| | |
| | Description |
| | |
+--------+---------------------------------------------------+
| 5.4.0 | |
| | |
| | The TZ environment variable is no longer used to |
| | guess the timezone. |
| | |
| 5.4.0 | |
| | |
| | The timezone is no longer guessed from informa- |
| | tion available through the operating system as |
| | the guessed timezone can not be relied on. |
| | |
+--------+---------------------------------------------------+
EXAMPLES
Example #1
Getting the default timezone
<?php
date_default_timezone_set('Europe/London');
if (date_default_timezone_get()) {
echo 'date_default_timezone_set: ' . date_default_timezone_get() . '<br />';
}
if (ini_get('date.timezone')) {
echo 'date.timezone: ' . ini_get('date.timezone');
}
?>
The above example will output something similar to:
date_default_timezone_set: Europe/London
date.timezone: Europe/London
Example #2
Getting the abbreviation of a timezone
<?php
date_default_timezone_set('America/Los_Angeles');
echo date_default_timezone_get() . ' => ' . date('e') . ' => ' . date('T');
?>
The above example will output:
America/Los_Angeles => America/Los_Angeles => PST
SEE ALSO date_default_timezone_set(3), "List of Supported Timezones".
PHP Documentation Group DATE_DEFAULT_TIMEZONE_GET(3)