The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



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
Getting latest file from ftp arunavlp UNIX for Dummies Questions & Answers 3 02-08-2008 10:19 AM
How Can I Easily Determine If A File Has been Added to a Directory goodmis UNIX for Advanced & Expert Users 7 02-04-2007 01:13 AM
How Can I Easily Determine If A File Has been Added to a Directory goodmis UNIX for Dummies Questions & Answers 1 01-31-2007 06:56 PM
Moving part of Text in a file mgirinath Shell Programming and Scripting 4 02-06-2006 06:04 PM
How to scan only new lines added in file? redlotus72 UNIX for Dummies Questions & Answers 3 04-28-2005 04:34 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-23-2008
pcrs pcrs is offline
Registered User
  
 

Join Date: Feb 2007
Location: Sweden
Posts: 7
Get the latest added part of a text file?

Hi,
I want to get the latest added part of a text file sent over the network to for analysis. Is there a tool to use to keep track of which part of a text file that has already been analysed so only the "new" lines will be sent and handled? I have checked a few tools but I still don´t know how to solve this. Rsync seems to be able to copy the latest added content of a file in an "incremental way" but I don´t know how to take care of this "incremental content" in a script.
Do you have any ideas?
  #2 (permalink)  
Old 10-23-2008
DukeNuke2's Avatar
DukeNuke2 DukeNuke2 is online now Forum Staff  
Soulman
  
 

Join Date: Jul 2006
Location: Germany, Berlin
Posts: 3,020
i dnon't know if there is a tool to do what you want. but how about this workaround?

after every analyse make a copy of the file. before every new analyse look for the "diff" and only analyse these differences... this can be done very easy with some lines of shell script code!

hth,
DN2
  #3 (permalink)  
Old 10-23-2008
joeyg's Avatar
joeyg joeyg is offline Forum Staff  
modérateur
  
 

Join Date: Dec 2007
Location: Home of 17-time world champion Boston Celtics
Posts: 1,311
Wink What about this?

If the data is appended to the file, then perhaps...
(the following is a rough coding; there are issues with spacing and field layouts known)

analyze data as normal
wc -l mydatafile >mydatafile.last

next time to analyze
newcnt=$(wc -l mydatafile)
lastcnt=$(cat mydatafile.last)
newlines=$(echo $newcnt - $lastcnt | bc)

now, a tail command could provide you with the last lines to review
  #4 (permalink)  
Old 10-27-2008
pcrs pcrs is offline
Registered User
  
 

Join Date: Feb 2007
Location: Sweden
Posts: 7
Thanks for your help. I will probably use the diff command to get the latest content of the textfile.
Closed Thread

Bookmarks

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 06:34 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0