tail

Send grepped tail output to netcat

我怕爱的太早我们不能终老 提交于 2021-01-28 14:27:08
问题 I am trying to run the following command, and nothing is getting sent to netcat tail -F file.txt | grep test | nc host 9999 If I remove the grep, the tail successfully is followed and sent to netcat. If I just run the following, data comes back, so I know that data should be getting sent to the nc pipe: tail -F file.txt | grep test Any ideas? UPDATE I added the following to unbuffer the piped output and nothing goes through: tail -F file.txt | stdbuf -o0 grep test | nc host 9999 When I turn

bash tail the newest file in folder without variable

荒凉一梦 提交于 2021-01-19 08:28:12
问题 I have a bunch of log files in a folder. When I cd into the folder and look at the files it looks something like this. $ ls -lhat -rw-r--r-- 1 root root 5.3K Sep 10 12:22 some_log_c48b72e8.log -rw-r--r-- 1 root root 5.1M Sep 10 02:51 some_log_cebb6a28.log -rw-r--r-- 1 root root 1.1K Aug 25 14:21 some_log_edc96130.log -rw-r--r-- 1 root root 406K Aug 25 14:18 some_log_595c9c50.log -rw-r--r-- 1 root root 65K Aug 24 16:00 some_log_36d179b3.log -rw-r--r-- 1 root root 87K Aug 24 13:48 some_log

如何实现Linux下高亮关键字的tail -f功能

拥有回忆 提交于 2020-12-08 07:48:30
公司内部一哥们发布到邮件列表中的一个小tip,挺有意思,属于程序员的“奇淫技巧”类吧,值得记录一下。 如果你在linux下工作,那用tail -f跟踪一个日志文件的输出内容应该是家常便饭了。 但是,有时你更关心的是一些敏感字词,希望能够在动态跟踪的同时,把这些字词高亮出来,比如日志中的ERROR关键字。 那么,一种思路就是把你tail输出的东西再做一次包装处理,这个很符合linux管道处理的思想。 以高亮Log中的ERROR为例,你可以这样: tail -f xxx.log | perl -pe 's/(ERROR)/\e[1;31m$1\e[0m/g' 其中,xxx.log是你要跟踪的文件。这里假设了你的Linux的PATH中有perl。perl在这里干的事情,就是通过命令行的方式进行动态的替换ERROR字符串的操作,替换过程中,主要使用了Linux的console_codes的语法结构。(具体关于console_codes的细节,可以通过man console_codes进行了解)这里,\e主要进行转移说明。 如果你手头有server log之类的日志,试试上面的命令,是不是把ERROR全部标红了。 利用这个原理,你完全可以按照你所需要的颜色高亮你感兴趣的输出,具体的颜色说明,可以在man console_codes中查到。 另外,less本身也支持类似于tail -f的操作

Minimum Websocket Nodejs Tail Example

女生的网名这么多〃 提交于 2020-07-16 16:13:07
问题 I'm trying to create a stream of data to the browser using websocket. The data is the output of a log file. (tail -f filename) Using node js, I've manage to log into stdout, but I haven't been able to create the server and create the client (js/html) code to create a websocket and receive all the output of this child process. Can anyone help me? NODE.JS SERVER OUTPUTTING TAIL TO STDOUT (as seen in http://snippets.dzone.com/posts/show/12067) var sys = require('sys') var spawn = require('child

Minimum Websocket Nodejs Tail Example

不羁岁月 提交于 2020-07-16 16:12:39
问题 I'm trying to create a stream of data to the browser using websocket. The data is the output of a log file. (tail -f filename) Using node js, I've manage to log into stdout, but I haven't been able to create the server and create the client (js/html) code to create a websocket and receive all the output of this child process. Can anyone help me? NODE.JS SERVER OUTPUTTING TAIL TO STDOUT (as seen in http://snippets.dzone.com/posts/show/12067) var sys = require('sys') var spawn = require('child

How can I tail a remote binary file?

我只是一个虾纸丫 提交于 2020-06-17 15:57:05
问题 I'm looking for a way to stream ("tail") a binary file on a Kubernetes pod to my local machine. I've tried this: kubectl exec -it app-service-58697cf7c9-nnzgh -c tcpdumper -- tail -f -c +0 /output.pcap ( tcpdumper is just a thin wrapper around tcpdump which runs as a helper container in the pod). This almost works. I'm able to view a stream of binary data on my local machine when I run this command. The end goal of what I'm trying to do here is that I'd like to take this binary stream of pcap

How to use while read line with tail -n

我的梦境 提交于 2020-04-11 07:15:08
问题 Problem: I have a CSV dump file - with excess of 250,000 lines. When I use while read - it takes a while (no pun intended). I would like to go back to the last 10,000 lines to do what I need to do instead of the 250,000 lines. Code Snippet: My current code is this: IFS="," while read line do awk_var=`echo "$line" | awk -F" " '{print $0}'` var_array=($awk_var) read -a var_array <<< "${awk_var}" echo "${var_array[1]}" done </some_directory/directory/file_in_question.csv Question: How can I use

How to use while read line with tail -n

拥有回忆 提交于 2020-04-11 07:14:08
问题 Problem: I have a CSV dump file - with excess of 250,000 lines. When I use while read - it takes a while (no pun intended). I would like to go back to the last 10,000 lines to do what I need to do instead of the 250,000 lines. Code Snippet: My current code is this: IFS="," while read line do awk_var=`echo "$line" | awk -F" " '{print $0}'` var_array=($awk_var) read -a var_array <<< "${awk_var}" echo "${var_array[1]}" done </some_directory/directory/file_in_question.csv Question: How can I use

PowerShell equivalent for “head -n-3”?

元气小坏坏 提交于 2020-04-08 01:31:48
问题 I've been able to track down basic head/tail functionality: head -10 myfile <==> cat myfile | select -first 10 tail -10 myfile <==> cat myfile | select -last 10 But if I want to list all lines except the last three or all lines except the first three, how do you do that? In Unix, I could do "head -n-3" or "tail -n+4". It is not obvious how this should be done for PowerShell. 回答1: Like the -First and -Last parameters, there is also a -Skip parameter that will help. It is worth noting that