Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SED , trying to extract data by the given range 1

Status
Not open for further replies.

alibaba786

Programmer
Feb 27, 2009
4
DE
Hi,
I am trying to extract data from the log files by the given date range.

for example:
extract info 2009-02-17 08:02:16 to 2009-02-17 14:50:40

2009-02-17 08:02:16> [INFO] Shutdown Init pin is set
2009-02-17 08:02:16> [INFO] 2009-02-17 09:02:16.4428
2009-02-17 08:02:16> [INFO] Shutdown process started
2009-02-17 08:02:16> [INFO] Shutdown appended to /var/opt
2009-02-17 08:02:16> [INFO] Logfile moved to /var/opt
2009-02-17 08:02:16> [INFO] Prepare for shutdown Tue Feb 17
2009-02-18 14:50:40> [INFO] Start of Ocean on ocean5476
2009-02-18 14:50:40> [INFO] =
2009-02-18 14:50:40> [INFO] System version 6.2.0.26
2009-02-18 14:50:40> [INFO] HW version 2.4
2009-02-18 14:50:40> [INFO] Ocean version 5.6.5
...


Here you can notice, date is variable in each line

Can someone help me in this regard
 
alibaba786,

How about using awk?

awk '/^2009-02-17 08:02:16/,/2009-02-17 14:50:40/' testfile

Hope that helps.

John
 
Sed works too...
Code:
sed -n '/^2009-02-17 08:02:16/,/^2009-02-17 14:50:40/p' testfile


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top