tail

how to continuously display a file of its last several lines of contents

天涯浪子 提交于 2019-12-31 10:34:07
问题 I am trying to find a Unix command (combination, maybe) on how to continuously display a file of its last several lines of contents. But during this displaying, I want some of the top lines are always displayed on the screen top when the rolling contents reach the screen top. Is that possible? (1) Suppose I have file, "job.sta", the first 2 lines are: job name, John's job on 2013-Jan-30,... Tab1, Tab2, Tab3 0, 1, 2, 1, 90, 89 2, 89, 23 ... (2) This file is on its running, its contents are

how to continuously display a file of its last several lines of contents

♀尐吖头ヾ 提交于 2019-12-31 10:34:03
问题 I am trying to find a Unix command (combination, maybe) on how to continuously display a file of its last several lines of contents. But during this displaying, I want some of the top lines are always displayed on the screen top when the rolling contents reach the screen top. Is that possible? (1) Suppose I have file, "job.sta", the first 2 lines are: job name, John's job on 2013-Jan-30,... Tab1, Tab2, Tab3 0, 1, 2, 1, 90, 89 2, 89, 23 ... (2) This file is on its running, its contents are

Tail recursive maximum depth method of binary tree in Scala

情到浓时终转凉″ 提交于 2019-12-31 05:42:37
问题 I wrote a method to calculate the maximum depth of a binary tree. I would like to write a tail recursive method. I thought of using lists, but I didn't find solutions This is my method that is not tail recursive: def depth: Int = { def iter(f: FormulaWff): Int = f match { case Var(_) => 0 case Not(e1) => 1 + iter(e1) case And(e1, e2) => 1 + Math.max(iter(e1), iter(e2)) case Or(e1, e2) => 1 + Math.max(iter(e1), iter(e2)) case Implies(e1, e2) => 1 + Math.max(iter(e1), iter(e2)) } iter(this) }

Java RandomAccessFile.java under linux not working correctly

邮差的信 提交于 2019-12-31 04:20:10
问题 Im trying to implement the simple tail -f linux command in java. Here is my code. try { // position within the file File file = new File("/home/curuk/monitored/log.txt"); RandomAccessFile raFile = new RandomAccessFile(file, "r"); long last = file.lastModified(); // The last time the file was checked for changes long position = file.length(); while (true) { if (file.lastModified() > last) { last = file.lastModified(); readFromFile(raFile, (int) position, (int) (file.length() - position));

Dropping all left NAs in a dataframe and left shifting the cleaned rows

ε祈祈猫儿з 提交于 2019-12-31 02:39:25
问题 I have the following dataframe dat , which presents a row-specific number of NAs at the beginning of some of its rows: dat <- as.data.frame(rbind(c(NA,NA,1,3,5,NA,NA,NA), c(NA,1:3,6:8,NA), c(1:7,NA))) dat # V1 V2 V3 V4 V5 V6 V7 V8 # NA NA 1 3 5 NA NA NA # NA 1 2 3 6 7 8 NA # 1 NA 2 3 4 5 6 NA My aim is to delete all the NAs at the beginning of each row and to left shift the row values (adding NAs at the end of the shifted rows accordingly, in order to keep their length constant). The

tail -f into grep into cut not working properly

时间秒杀一切 提交于 2019-12-29 06:40:07
问题 i'm trying to build a shell script to monitor some log files. I'm using a command like this: tail -f /var/somelog | grep --line-buffered " some test and p l a c e h o l d e r" | cut -f 3,4,14 -d " " the log file is like: some test and p l a c e h o l d e r 3 some test and p l a c e h o l d e r 4 some test and p l a c e h o l d e r 5 some test and p l a c e h o l d e r 6 and so on.. My issue is that the output of the command does not display the last line some test and p l a c e h o l d e r 6

tail -f into grep into cut not working properly

南笙酒味 提交于 2019-12-29 06:39:08
问题 i'm trying to build a shell script to monitor some log files. I'm using a command like this: tail -f /var/somelog | grep --line-buffered " some test and p l a c e h o l d e r" | cut -f 3,4,14 -d " " the log file is like: some test and p l a c e h o l d e r 3 some test and p l a c e h o l d e r 4 some test and p l a c e h o l d e r 5 some test and p l a c e h o l d e r 6 and so on.. My issue is that the output of the command does not display the last line some test and p l a c e h o l d e r 6

R: How to get the last element from each group?

偶尔善良 提交于 2019-12-29 01:53:11
问题 I have a data frame containing a time series with two time stamp columns, d$day and d$time , and say, for simplicity, one measured variable d$val1 . Suppose I want to examine the situation at the close of each day's experiment, i.e. the last measurement, if it exists. (Not every day has a measurement, and measurements can be taken at different times each day.) I would like to be able to aggregate by day and use some sort of last() or tail() function on time to pull back the corresponding val

Unix tail program in C using an implemented function

时间秒杀一切 提交于 2019-12-25 18:53:45
问题 I have implemented my own dynamic-memory version of getline function: char * fgetline(FILE * f) Starts with 30 character buffer and when the buffer is full allocate a new one copy the contents and free the old buffer. When we get EOF or \n we return from the function. I want to use this function to implement a version of the program tail. Input comes from stdin, output goes to stdout. If the first argument begins with - , everything after the - is the number of lines to print. The default

Command line: monitor log file and add data to database

被刻印的时光 ゝ 提交于 2019-12-24 20:09:40
问题 I'm monitoring a log file. Each line has the following format: 2012 5 29 14 20 438.815 872.737 -1.89976 -0.55156 8.68749 -0.497848 -0.54559 0 0 6 00 0 0 0 0 0 0 0 0 80 9 0 0 10 0 0 0 8 00 9 0 0 0 0 0 0 2 41 84 0 0 0 1 0 As you can see, each value is delimited by a tab. How can I write a Perl script to take each new line of data (the log file is updated every ten minutes) and insert this data into a MySQL database? I'd like to do as much of this as possible on the command line. If I do tail -f