tail

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

让人想犯罪 __ 提交于 2019-11-26 10:57:56
问题 this command is really very useful but where I can get the source code to see what is going on inside . thanks . 回答1: The tail utility is part of the coreutils on linux. Source tarball: ftp://ftp.gnu.org/gnu/coreutils/coreutils-7.4.tar.gz Source file: http://git.savannah.gnu.org/cgit/coreutils.git/tree/src/tail.c I've always found FreeBSD to have far clearer source code than the gnu utilities. So here's tail.c in the FreeBSD project: http://svnweb.freebsd.org/csrg/usr.bin/tail/tail.c?view

Unix tail equivalent command in Windows Powershell

陌路散爱 提交于 2019-11-26 06:51:08
问题 I have to look at the last few lines of a large file (typical size is 500MB-2GB). I am looking for a equivalent of Unix command tail for Windows Powershell. A few alternatives available on are, http://tailforwin32.sourceforge.net/ and Get-Content [filename] | Select-Object -Last 10 For me, it is not allowed to use the first alternative, and the second alternative is slow. Does anyone know of an efficient implementation of tail for PowerShell. 回答1: Use the -wait parameter with Get-Content,

A Windows equivalent of the Unix tail command [closed]

浪尽此生 提交于 2019-11-26 03:19:11
问题 I\'m looking for the equivalent of the Unix \'tail\' command that will allow me to watch the output of a log file while it is being written to. 回答1: I'd suggest installing something like GNU Utilities for Win32. It has most favourites, including tail. 回答2: If you use PowerShell then this works: Get-Content filenamehere -Wait -Tail 30 Posting Stefan's comment from below, so people don't miss it PowerShell 3 introduces a -Tail parameter to include only the last x lines 回答3: I've always used

How to 'grep' a continuous stream?

ぐ巨炮叔叔 提交于 2019-11-26 01:27:26
问题 Is that possible to use grep on a continuous stream? What I mean is sort of a tail -f <file> command, but with grep on the output in order to keep only the lines that interest me. I\'ve tried tail -f <file> | grep pattern but it seems that grep can only be executed once tail finishes, that is to say never. 回答1: Turn on grep 's line buffering mode when using BSD grep (FreeBSD, Mac OS X etc.) tail -f file | grep --line-buffered my_pattern You don't need to do this for GNU grep (used on pretty

Java IO implementation of unix/linux “tail -f”

独自空忆成欢 提交于 2019-11-26 01:27:19
问题 I\'m wondering what techniques and/or library to use to implement the functionality of the linux command \"tail -f \". I\'m essentially looking for a drop in add-on/replacement for java.io.FileReader . Client code could look something like this: TailFileReader lft = new TailFileReader(\"application.log\"); BufferedReader br = new BufferedReader(lft); String line; try { while (true) { line= br.readLine(); // do something interesting with line } } catch (IOException e) { // barf } The missing

Get last n lines of a file with Python, similar to tail

末鹿安然 提交于 2019-11-26 01:20:02
问题 I\'m writing a log file viewer for a web application and for that I want to paginate through the lines of the log file. The items in the file are line based with the newest item on the bottom. So I need a tail() method that can read n lines from the bottom and supports an offset. What I came up with looks like this: def tail(f, n, offset=0): \"\"\"Reads a n lines from f with an offset of offset lines.\"\"\" avg_line_length = 74 to_read = n + offset while 1: try: f.seek(-(avg_line_length * to

How can I tail a log file in Python?

醉酒当歌 提交于 2019-11-25 23:46:45
问题 I\'d like to make the output of tail -F or something similar available to me in Python without blocking or locking. I\'ve found some really old code to do that here, but I\'m thinking there must be a better way or a library to do the same thing by now. Anyone know of one? Ideally, I\'d have something like tail.getNewData() that I could call every time I wanted more data. 回答1: Non Blocking If you are on linux (as windows does not support calling select on files) you can use the subprocess