tail

Batch file to output last line of findstr

不打扰是莪最后的温柔 提交于 2019-12-04 05:26:11
问题 I am trying to find a list of machines in files in folders, and print out the last line of the output only. @echo off for /f %%a in (computers.txt) do findstr /xs "%%a" unhealthy.txt pause The computers.txt file has a list of 300 machines. I want that to output only the last line of each instance it finds. Right now the command displays and outputs all instances of the computer name, not just the tail end. I've tried to use "tail for Windows" but am getting errors as well. Current output:

Incorrect results with bash process substitution and tail?

孤街浪徒 提交于 2019-12-04 00:19:24
Using bash process substitution, I want to run two different commands on a file simultaneously. In this example it is not necessary but imagine that "cat /usr/share/dict/words" was a very expensive operation such as uncompressing a 50gb file. cat /usr/share/dict/words | tee >(head -1 > h.txt) >(tail -1 > t.txt) > /dev/null After this command I would expect h.txt to contain the first line of the words file "A", and t.txt to contain the last line of the file "Zyzzogeton". However what actually happens is that h.txt contains "A" but t.txt contains "argillaceo" which is about 5% into the file. Why

Java “tail -f” wrapper

断了今生、忘了曾经 提交于 2019-12-03 20:18:56
I need to wrap the Unix command "tail -f" in a BufferedInputStream. I don't want to simulate or mimic tail as stated by this question . Rather, I want to use tail, waiting for it to give me a new line. Your best bet is to use the Process class and read with a Scanner : Runtime r = Runtime.getRuntime() Process p = r.exec("tail -f") Scanner s = new Scanner(p.getInputStream()) while (s.hasNextLine()) { String line = s.nextLine() // Do whatever you want with the output. } hasNextLine() should block as it's waiting for more input from the input stream, so you will not be busy-waiting as data comes

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

戏子无情 提交于 2019-12-03 17:24:11
What is 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. Sounds like a good job for RRDTool . But if you want to stick with Python, I would use tail to stream the data into my program (this is assuming the file is continuously written to, otherwise a straight open() in Python will work). tail -F data.log | python myprogram.py myprogram.py could look something like: import sys p = ... # create a pylab plot instance for line in sys

grep for text with wild card in between

痞子三分冷 提交于 2019-12-03 15:22:59
问题 I would like to grep something like ==> *.sh <== . But it doesn't work, I can grep everything up to .sh <== but not get the wild card to work. What's the trick here? 回答1: You need to grep for something like "==> .*\.sh <==" The .* part matches any character for any length, the \. part matches a dot. 来源: https://stackoverflow.com/questions/5906228/grep-for-text-with-wild-card-in-between

How to keep log tail alive on Heroku using ssh?

折月煮酒 提交于 2019-12-03 14:33:07
Using heroku logs --tail which works great for a few minutes. Then it stops displaying the logs. It seems that the ssh connection is timing out and dying. There is no error or message. Working in Ubuntu 11.04 on wired conneciton. I added the following to ~/.ssh/config: ServerAliveInterval 5 But it didn't work. Do I need anything else in the config file? How do I know if it is doing anything? How can I monitor the traffic and see the keepalive request? I am looking at System Monitor but don't see anything every 5 seconds. Thanks. Have you done all of this: $ heroku config:add LOG_LEVEL=DEBUG $

pipe tail output into another script

左心房为你撑大大i 提交于 2019-12-03 13:03:32
问题 I am trying to pipe the output of a tail command into another bash script to process: tail -n +1 -f your_log_file | myscript.sh However, when I run it, the $1 parameter (inside the myscript.sh) never gets reached. What am I missing? How do I pipe the output to be the input parameter of the script? PS - I want tail to run forever and continue piping each individual line into the script. Edit For now the entire contents of myscripts.sh are: echo $1; 回答1: Generally, here is one way to handle

Tailing Rolling Files

霸气de小男生 提交于 2019-12-03 10:27:32
I have a directory full of rolling log files that I would like to be able to use tail on. The files are named as such: name modified 00A.txt Dec 27 19:00 00B.txt Dec 27 19:01 00C.txt Dec 27 19:02 00D.txt Dec 27 19:03 On an older unix system, I'm trying to come up with a shell script that will tail the most recently modified file in a specific directory, and if that file gets administratively closed (rolls to the next file) I want the program to automatically begin tailing the new file without me having to break out of tail to rerun. tail -100f `ls -t | head -1` The desired behavior, given the

grep for text with wild card in between

泄露秘密 提交于 2019-12-03 04:57:26
I would like to grep something like ==> *.sh <== . But it doesn't work, I can grep everything up to .sh <== but not get the wild card to work. What's the trick here? You need to grep for something like "==> .*\.sh <==" The .* part matches any character for any length, the \. part matches a dot. 来源: https://stackoverflow.com/questions/5906228/grep-for-text-with-wild-card-in-between

How to tail all the log files inside a folder and subfolders?

守給你的承諾、 提交于 2019-12-03 04:06:52
问题 In Linux, using the command tailf , how can I tail several log files that are inside a folder and in the subfolders? 回答1: To log all the files inside a folder, you can go to the folder and write tailf *.log To add the subfolders to the tailf command, use tailf **/*.log Instead of tailf you can also use tail -f . Of course, the regular expression can be improved to match only specific file names. 回答2: This will recursively find all *.log files in current directory and its subfolders and tail