SunQuest
           Other Programming Languages
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreOther Programming Languages

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!
  #1  
Old February 27th, 2008, 05:25 AM
qwertys21 qwertys21 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2008
Posts: 2 qwertys21 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 m 4 sec
Reputation Power: 0
General - Last entry in a file.

Does anyone know how I can read/report/display the last entry in a file? I have a file that I receive everyday but I want to only be able to report out the last entry or display the last entry as the file is quite large but new entries get written to it on a daily basis.

In such I will like it to display only entry for each current day from a big file.

I am no programmer so please will like your help for something simple.

Thanks

Reply With Quote
  #2  
Old February 27th, 2008, 06:08 PM
NovaX NovaX is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2005
Location: Bay Area, California
Posts: 389 NovaX User rank is First Lieutenant (10000 - 20000 Reputation Level)NovaX User rank is First Lieutenant (10000 - 20000 Reputation Level)NovaX User rank is First Lieutenant (10000 - 20000 Reputation Level)NovaX User rank is First Lieutenant (10000 - 20000 Reputation Level)NovaX User rank is First Lieutenant (10000 - 20000 Reputation Level)NovaX User rank is First Lieutenant (10000 - 20000 Reputation Level)NovaX User rank is First Lieutenant (10000 - 20000 Reputation Level)NovaX User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Week 3 Days 15 h 5 m 21 sec
Reputation Power: 106
Send a message via ICQ to NovaX
How is the file structured? If its a CSV file, it could be as simple as using the "tail" unix command to retrieve the last row (line). There are various approaches, depending on how the file is formatted.

Reply With Quote
  #3  
Old February 28th, 2008, 01:47 AM
DevCoach DevCoach is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Feb 2004
Location: London, England
Posts: 1,195 DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 1 Week 5 Days 13 h 31 m 54 sec
Reputation Power: 252
You have not given sufficient information to answer this -

* what OS is it on - Unix, Linux, MacOS, Windows?

* what is the file format?
* is it text or binary?
* how are the entries defined?

As NovaX says, if the file is text and if the entries are single lines, and if you are on a UNIXy machine, then you can do it with tail -n1 <filename>.

But that is a lot of ifs. If the file is an Access database on Windows then the answer is going to be very different.

Dave

Reply With Quote
  #4  
Old February 29th, 2008, 05:25 AM
qwertys21 qwertys21 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2008
Posts: 2 qwertys21 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 m 4 sec
Reputation Power: 0
Hi Hi and thanks for your response.

No it is not a CSv.

It is log files from Cisco switches so it is a txt docuemnt. I am using WindowsXP.

Entries are defined as such.
Feb 15 23:57:17: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/20, changed state to up
Feb 16 01:04:36: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to down
Feb 16 01:04:37: %LINK-3-UPDOWN: Interface FastEthernet0/1, changed state to down
Feb 16 01:04:39: %LINK-3-UPDOWN: Interface FastEthernet0/1, changed state to up
Feb 16 01:04:40: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up
Feb 16 01:04:49: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to down
Feb 16 01:04:51: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up
Feb 16 22:10:27: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/10, changed state to down
Feb 16 22:10:28: %LINK-3-UPDOWN: Interface FastEthernet0/10, changed state to down
Feb 16 22:10:30: %LINK-3-UPDOWN: Interface FastEthernet0/10, changed state to up

I will really ike the last 10 or 20 entries or entries that appear on certain dates.

Thanks

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreOther Programming Languages > General - Last entry in a file.


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway