|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here! |
|
#1
|
|||
|
|||
|
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 |
|
#2
|
|||
|
|||
|
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.
|
|
#3
|
|||
|
|||
|
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 |
|
#4
|
|||
|
|||
|
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 |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Other Programming Languages > General - Last entry in a file. |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|