FAQ Database Discussion Community


Unix - Tail Utility would open the file or not

unix,logic,tail
Can anybody help me to sort this out. What is the logic of Tail -f utility in Unix. Is it open the log file to check the updated content or is there any other way to get this information. All the implimentation of Tail utility says that it will open...

How to find latest equal element in two linked lists?

algorithm,search,linked-list,tail
There is two linked lists. They have common tail. I want to find latest element, which is the same in both lists. For example, List1 is 10->4->5->2->9->53->64->345->23 List2 is 10->4->5->2->8->53->64->345->23->43->53 I want to find 2. We can iterate over list in O(n). Is there a better way to find needed...

Tail command - follow by name on Solaris

filenames,solaris,file-descriptor,tail
Is there a way to tail a file by name on Solaris 10? Equivalent to: tail --follow=name Manual for tail on solaris shows no such option. Only -f is included and it looks like it follows a file by descriptor....

Streaming/Tailing data over SSH using C# with SSH.NET leaks memory

c#,ssh,tail,ssh.net
I'm trying to tail a file over SSH using C#. This file with be read from the beginning and then continue to be monitored for hours at a time maintaining the SSH connection. I'm using SSH.NET library to provide the functionality to SSH. The file size can be anywhere up...

Formatting Errors with tail

linux,bash,unicode,cygwin,tail
How can I correctly parse this file through tail, without formatting errors? I am using tail within cygwin to parse the last ten lines of two files. One file parses through correctly, the other contains a space between every character. $ tail file2.txt -n 4 22/06/2015 12:28 - Decompressing and...

python monitor a log file non blocking

python,logging,generator,tail
I have a test stub that will write several log messages to the system log. But, this system log gets updated by many other applications as well. So, basically, I want to do a tail -f system.log | grep "application name" to get only the appropriate log messages. I was...

Node.js Library to start tailing a file from specific line or line number?

node.js,tail
I am searching for library/module that starts tailing from a specific line number so that even if my server dies down or restarts it should start from the last read line. I am little new to node.js

In Perl, using File::Tail trying to grep pattern using regex, but $1 unintialised

regex,perl,tail
I am trying to continuously tail a growing file, and using regex to extract information whenever new lines are added to the file, but $1 does not seem to like it. Code #!/usr/bin/perl $| = 1; use strict; use warnings; use File::Tail; my $file=File::Tail->new( name=>"sample.txt", maxinterval=>1, interval=>0.05); while (defined(my $line=$file->read))...

linux - running a process and tailing a file simultaneously

bash,shell,tail
I want a run a long task on a remote machine (with python fabric using ssh). It logs to a file on the remote machine. What I want to do is to run that script and tail (actively display) the log file content until the script execution ends. The problem...

make a linked list with head and tail nodes

linked-list,head,tail
I am a newbie to data structure. When you make a linked list with head and tail nodes, why do I have to link new node to tail? Isn't it enough for tail.next to be linked to newNode? like this: public void add( Object data ) { ListNode newNode =...

Ring buffer log file on unix

unix,logging,pipeline,tail
I'm trying to come up with a unix pipeline of commands that will allow me to log only the most recent n lines of a program's output to a text file. The text file should never be more than n lines long. (it may be less when it is first...

Impose time limit to popen/fgets in PHP

php,amazon-web-services,tail,time-limiting
I want impose a time limit to a process reading using fgets opened by popen in PHP. I have the next code: $handle = popen("tail -F -n 30 /tmp/pushlog.txt 2>&1", "r"); while(!feof($handle)) { $buffer = fgets($handle); echo "data: ".$buffer."\n"; @ob_flush(); flush(); } pclose($handle); I tried without success: set_time_limit(60); ignore_user_abort(false); The...

Practicality of head and tail in a linked list

java,data-structures,linked-list,tail,head
From what I come to understand is that the head always point to the first node in the list. The tail always point to the last node in the list. Questions: 1) But in terms of practicality, why is having the tail useful? I understand having head is useful because...

dplyr and tail to change last value in a group_by in r

r,dplyr,tail
while using dplyr i'm having trouble changing the last value my data frame. i want to group by user and tag and change the Time to 0 for the last value / row in the group. user_id tag Time 1 268096674 1 3 2 268096674 1 10 3 268096674 1...

Read unix log for message and then perform action

bash,grep,tail
I am looking to create a shell script to read the message log and when finds the correct string perform an action. So far I have the following: #!/bin/bash string="ntp engine ready" tail -n 0 -f /var/log/messages | \ while read LINE do echo "$LINE | grep -q $string" if...

Apply function iteratively across a dataframe

r,data.frame,tail,cbind
I have a two-part question for applying a function across a dataset in R. i) Firstly, I have 2 data frames that I would like to be combined and paired iteratively, so that something like a cbind function would line up the 1st columns of each data frame next to...

Unix head/tail a percentage of lines to an output file

unix,lines,percentage,head,tail
I'm using unix to read through an excel file, sort by one column, and then I want a percentage (lets say the top 10%) of the sorted lines exported to a new .xls file. I have the code below which works fine but I need to do a wc -l...

Selecting the nth character within a loop using R

r,loops,head,tail
For context, I am writing a code in R that selects out the most common character from a list of strings - determining the most common character in the first position of each string, and so on. To start I am running a loop within a loop to save each...

Pipe continuous stream to another command

awk,stream,pipe,tail
I wrote a program to analyze the log files in real time. I need to feed it with the IPs. It works fine with the command: cat /var/log/apache2/access.log | awk '{print $1}' | ./my_program Also, I can get the IPs in real time with the command: tail -f /var/log/apache2/access.log | awk '{print...

Generic tail in Swift

swift,generics,tail
tail for array: private extension Array { var tail: Array { get { return Array(dropFirst(self)) } } } And here is generic version for Sliceable: public func tail<S: Sliceable>(sequence: S, initializer: ((S.SubSlice) -> S)) -> S { return initializer(dropFirst(sequence)) } let s = tail("12", {String($0)}) Is it possible to rewrite...

libgdx drawing tail of moving object

libgdx,tail
I'm using libgdx and try to draw a tail of a moving object! To do this I have to calculate the coordinates of the object's position a few seconds before present time. Is there an easy way to do this? Thanks for helping! ...