473,386 Members | 1,785 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

tail with line feed delimination

Im trying to tail a file that does not have hard returns but has line feeds after each entry. Is there a way to change the standard file tail settings to look for line feeds when tailing?
Aug 6 '07 #1
6 1791
I know how to do this to the entire file via the unix2dos commands in order for tail to work properly.

Im wondering if I can change the file as it is written? That would be ideal in order to provide a working tail. Otherwise to change the line feed to a hard return right before it gets tailed.

Not sure if this would even be possible but it would save alot of time if I could.
Aug 6 '07 #2
numberwhun
3,509 Expert Mod 2GB
So what is writing this file? Is it a program? Is it Perl? Just curious.

Regards,

Jeff
Aug 6 '07 #3
Its a program on a unix system and between each write it puts in two line feeds.

The File tail module doesn't understand line feeds as the end of a line and will read through the entire file as one line.

So, since I cant get the app to write the log entries with a hard return I'm stuck trying to find a way to manipulate the file prior to tailing it.
Aug 6 '07 #4
numberwhun
3,509 Expert Mod 2GB
As far as you mentioned earlier about changing the way the program writes, that solution would be up to you to research as this is a Perl forum. Otherwise, you could create a script that would translate the single line feed into what you want it to have.

ie:
Expand|Select|Wrap|Line Numbers
  1. s/pattern/replacement/g
Something like that, but for each line in the file. Is it the Unix version you want (single line feed) or the dos version (carraige return/line feed)? Either way, if unix2dos works for you, why not write a Perl script that utilizes it and simply feeds each file name through it?

Regards,

Jeff
Aug 6 '07 #5
KevinADC
4,059 Expert 2GB
maybe if you redefine the input record seperator before trying to tail the file it will work:

$/ = "\r\r";

or whatever two line feeds is. Might want to wrap that in a block and use "local" so it dos not affect therest of your program if there is any:

{
local $/ = "\r\r";
your tail code here
}
Aug 6 '07 #6
miller
1,089 Expert 1GB
According to the Tail::File module docs:

TO BE DONE

Planned for 1.0: Using $/ instead of \n to separate "lines" (which should make it possible to read wtmp type files). Except that I discovered I have no need for that enhancement If you do, feel free to send me the patches and I'll apply them - if I feel they don't add too much processing time.
If I were you, I would therefore download this module, and edit the source in order to work with $/ instead of a hardcoded \n. However, this may be beyond the skill or interest you have for this project.

It's also possible that this module would work as is using the "tie'd" method described in the docs along with $/. I kinda of doubt it though.

That's all I have to suggest.

- Miller
Aug 6 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Count Dracula | last post by:
Is there a way to write a c++ program that will print out the last few lines of a file without reading the whole file? The implementations of 'tail' I have seen all appear to be system dependent....
10
by: Mel | last post by:
i need to create a unix like "tail" function on my site. the question: the text is displayed in a scrolled area and a new line is added at the end and the entire text is scrolled down so that...
12
by: s99999999s2003 | last post by:
hi I have a file which is very large eg over 200Mb , and i am going to use python to code a "tail" command to get the last few lines of the file. What is a good algorithm for this type of task...
19
by: Kay Schluehr | last post by:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/496691
1
by: Nalaka | last post by:
Hi, We are sending SMS messages using our ASDP.net site (C# code).... How do I add a "Line Feed" character to the string that we are sending? Any help is deeply appreciated Thanks Nalaka
1
by: cookspyder | last post by:
So I have this script and it works great at sending things over a socket after tailing a file. The problem seems to be when the recieving end is not available the program crashes. Is there a way to...
1
by: asdf | last post by:
Basically what i want to do is to read a file that is being constantly appended to but which is located on a remote server. I found this for doing BASH's tail -f in python: import os...
3
by: sab | last post by:
Hello, I have been working on a python script to parse a continuously growing log file on a UNIX server. The input is the standard in, piped in from the log file. The application works well...
35
by: Muzammil | last post by:
int harmonic(int n) { if (n=1) { return 1; } else { return harmonic(n-1)+1/n; } } can any help me ??
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.