![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| extract last modified time of file in form of YYYYMMDD | itsme_maverick | Shell Programming and Scripting | 3 | 05-28-2008 12:01 PM |
| Processing a log file based on date/time input and the date/time on the log file | primp | Shell Programming and Scripting | 4 | 03-16-2008 11:23 AM |
| Extract Date from file | magi | Shell Programming and Scripting | 2 | 09-30-2007 12:07 AM |
| Date and time log file | captoro | Shell Programming and Scripting | 8 | 09-03-2007 09:23 PM |
| extract date portion from file | misenkiser | Shell Programming and Scripting | 5 | 10-06-2006 05:37 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
How to extract date with time from file
Hi,
I have a file where there is a date and time field, the format for it is yyyy-mm-dd hours:mins:sec the position of date field may vary anywhere in the line and it might be different and it is specified along with the variable AppTimeStamp how do i extract date and time both from the line for eg . xxxxxxxxxxxxxxx<AppTimeStamp>09-10-2006 12:10:01<\AppTimeStamp>xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx<AppTimeStamp>10-12-02 10:05:00<\AppTimeStamoxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Please can anybody help me with this |
|
||||
|
Hi,
Thanks for the link, I tried the same, but it did not work, here is the sample file i am using <xxxx><xxxxx><xxxxx><AppEventTimeStamp>2006-05-02 09:25:00</AppEventTimeStamp><xxxx><xxxx>345</xxx><AppEventTimeStamp>2006-10-18 10:25:00</AppEventTimeStamp><xxxxxx><\xxxxxxxx> The format i am searching for is "year-mon-day hour-min-sec" could you please help me out with this |
|
||||
|
Python Alternative:
Code:
#!/usr/bin/python
import re #regular exp module
data = open("input.txt").read()
print re.findall("<AppEventTimeStamp>(.*?)</AppEventTimeStamp>",data)
Code:
['2006-05-02 09:25:00', '2006-10-18 10:25:00'] |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|