tail

Oddity with PHP tail -n 1 returning multiple results

I had this question... answered and very nice it was too. But, oddity has emerged whereby if the log file has a unique last line, (i.e. the first few words are different to the preceeding lines) it correctly returns that last line with tail -n 1 "file" but if the last few lines are similar to the the last line, it returns all the lines t...

Building grep strings dynamically

I am writing a shell script to do a "tail" on a growing log file. This script accepts parameters to search for, and incrementally greps the output on them. For example, if the script is invoked as follows: logs.sh string1 string2 it should translate to: tail -f logs.txt | grep string1 | grep string2 I am building the list of grep ...

How To watch a file write in PHP?

I want to make movement such as the tail command with PHP, but how may watch append to the file? ...

Value of the last element of a list

Hi, how to get the value of the last element of a List? I've noted that List.hd (or .Head) return an item, while List.tl (or .Tail) returns a List. Is rev the List and get the hd the only way around? Thanks. ...

How can I get the source code for the linux utility tail ?

Hi, this command is really very useful but where I can get the source code to see what is going on inside . thanks . ...

How to output lines 800-900 of a file with a unix command?

I want to output all lines between a and b in a file. This works but seems like overkill: head -n 900 file.txt | tail -n 100 My lack of unix knowledge seems to be the limit here. Any suggestions? ...

following a log file over http

For security reasons (I'm a developer) I do not have command line access to our Production servers where log files are written. I can, however access those log files over HTTP. Is there a utility in the manner of "tail -f" that can "follow" a plain text file using only HTTP? ...

How to get the PID of a process that is piped to another process in Bash?

Hi, I am trying to implement a simple log server in Bash. It should take a file as a parameter and serve it on a port with netcat. ( tail -f $1 & ) | nc -l -p 9977 But the problem is that when the netcat terminates, tail is left behind running. (Clarification: If I don't fork the tail process it will continue to run forever even the ...

How to implement a pythonic equivalent of tail -F?

What is the pythonic way of watching the tail end of a growing file for the occurrence of certain keywords? In shell I might say: tail -f "$file" | grep "$string" | while read hit; do #stuff done ...

tail read a growing dynamic file and extract two columns and then print a graph.

whats the best way to read a 1 GB file that gets time series data logged in it and generate a real time graph with two of its columns (one time and other a number)? I see that you have different ways of tailign the file. ...

Haskell tail function for empty lists

Hi, I have a problem with a function that should only return the tail of a list. The functions is myTail and should give a useable result, even if the input is an empty list. I want to understand all 3 ways: pattern matching, guarded equation and conditional expressions this works: >myTail_pat :: [a] -> [a] >myTail_pat (x:xs) = xs >m...

How to view a log file in Eclipse editor just like it looks in console window?

I have a txt log file. How to make it look in Eclipse editor just as if it was the console output [ eg links underlined ]. It is a bit sad plugins called "Log viewer" do not highlight links as Console Window does. That's the worst thing about such plugins. ...

Ending tail -f started in a shell script

What I have is following . A java process writing logs to the stdout A shell script starting the java process Another shell script which executes the previous one and redirects the log I check the log file with tail -f command for success message. The problem is even if I have exit 0 in the code I cannot end the tail -f process....

How do you continuously read a file in Java?

I'm trying to figure out how to continuously read a file and once there is a new line added, output the line. I'm doing this using a sleep thread however it just seems to blow through the whole file and exit the program. Any suggestions what I'm doing wrong? Here is my code: import java.io.*; import java.lang.*; import java.util....

join lists based on common head or tail

What is the fastest way to solve the following I will to join several lists based on common head or tail input = ([5,6,7], [1,2,3], [3,4,5], [8, 9]) output = [1, 2, 3, 4, 5, 6, 7] ...

"tailing" a binary file based on string location using bash?

I've got a bunch of binary files, each containing an embedded string near the end of the file but at different places (only occurs once in each file). I need to extract the part of the file starting at the location of the string till the end of the file and dump it into a new file. eg. If the file's contents is "AWREDEDEDEXXXERESSDSDS...

tailf for windows

I found tail2win but it is a paid product. Are there any good freeware or shareware out there? ...

Linux tail only whole words

Hello, I need to print last 20 characters of string, but only whole words. Delimiter is a space "". Let's consider this example: string="The quick brown fox jumps over the lazy dog" echo $string | tail -c20 returns s over the lazy dog. And I need it to return over the lazy dog instead. Do you know how to accomplish that...

How do I get the last non-empty line of a file using tail in Bash?

How do I get the last non-empty line using tail under Bash shell? For example, my_file.txt looks like this: hello hola bonjour (empty line) (empty line) Obviously, if I do tail -n 1 my_file.txt I will get an empty line. In my case I want to get bonjour. How do I do that? ...

Implement "tail -f" in C++

Hi! I want to create a small code in C++ with the same functionality as "tail-f": watch for new lines in a text file and show them in the standard output. The idea is to have a thread that monitors the file Is there an easy way to do it without opening and closing the file each time? ...