Questions tagged [tail]

The tail is the part of a list that comes after the head. It's also a unix command that shows the last lines of a file.

Depending on the context tail may refer to:

  • the part of a list that comes after the head i.e. the list you obtain when you remove the first element.

  • the tail unix command which displays the last lines of a file. It's counterpart which displays the first lines is head (). Example: tail -n 10 file will output last 10 lines of file.


See also:

1032 questions
864
votes
13 answers

How to 'grep' a continuous stream?

Is that possible to use grep on a continuous stream? What I mean is sort of a tail -f command, but with grep on the output in order to keep only the lines that interest me. I've tried tail -f | grep pattern but it seems that grep can…
Matthieu Napoli
  • 48,448
  • 45
  • 173
  • 261
492
votes
26 answers

A Windows equivalent of the Unix tail command

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.
Liam
  • 7,762
  • 4
  • 26
  • 27
456
votes
15 answers

Unix tail equivalent command in Windows Powershell

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…
mutelogan
  • 6,477
  • 6
  • 20
  • 15
210
votes
36 answers

Get last n lines of a file, similar to tail

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 at the bottom. So I need a tail() method that can read n lines from the…
Armin Ronacher
  • 31,998
  • 13
  • 65
  • 69
192
votes
11 answers

Printing the last column of a line in a file

I have a file that is constantly being written to/updated. I want to find the last line containing a particular word, then print the last column of that line. The file looks something like this. More A1/B1/C1 lines will be appended to it over…
Rayne
  • 14,247
  • 16
  • 42
  • 59
185
votes
9 answers

What's the opposite of head? I want all but the first N lines of a file

Given a text file of unknown length, how can I read, for example all but the first 2 lines of the file? I know tail will give me the last N lines, but I don't know what N is ahead of time. So for a file AAAA BBBB CCCC DDDD EEEE I want…
Nicholas M T Elliott
  • 3,643
  • 2
  • 19
  • 15
117
votes
5 answers

Tailing few lines from huge logs of kubectl logs -f

kubectl logs -f pod shows all logs from the beginning and it becomes a problem when the log is huge and we have to wait for a few minutes to get the last log. Its become more worst when connecting remotely. Is there a way that we can tail the logs…
Tinkaal Gogoi
  • 4,344
  • 4
  • 27
  • 36
116
votes
5 answers

Head and tail in one line

Is there a pythonic way to unpack a list in the first element and the "tail" in a single command? For example: >> head, tail = **some_magic applied to** [1, 1, 2, 3, 5, 8, 13, 21, 34, 55] >> head 1 >>> tail [1, 2, 3, 5, 8, 13, 21, 34, 55]
Giacomo d'Antonio
  • 2,215
  • 3
  • 19
  • 23
101
votes
14 answers

How can I tail a log file in Python?

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.…
Eli
  • 36,793
  • 40
  • 144
  • 207
76
votes
9 answers

Java IO implementation of unix/linux "tail -f"

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…
Gary
  • 6,357
  • 5
  • 30
  • 36
64
votes
5 answers

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

In Linux, using the command tailf, how can I tail several log files that are inside a folder and in the subfolders?
nakib
  • 4,304
  • 2
  • 28
  • 39
60
votes
2 answers

Get last line of shell output as a variable

I am working on a shell script with exiftool to automatically change some exif tags on pictures contained in a certain folder and I would like to use the output to get a notification on my NAS (a QNAP) when the job is completed. Everything works…
giopas
  • 645
  • 1
  • 6
  • 10
49
votes
8 answers

How can I tail a remote file?

I am trying to find a good way to tail a file on a remote host. This is on an internal network of Linux machines. The requirements are: Must be well behaved (no extra process laying around, or continuing output) Cannot require someone's pet Perl…
Frosty
  • 6,213
  • 3
  • 24
  • 20
44
votes
7 answers

Streaming log(txt) viewer

Anybody in the know of a viewer (or Notepad++ plugin) that can read txt files in a streaming way? I would like to see for example the last 10 lines of a txt file that gets appended continiously.
Boris Callens
  • 90,659
  • 85
  • 207
  • 305
40
votes
5 answers

Output file lines from last to first in Bash

I want to display the last 10 lines of my log file, starting with the last line- like a normal log reader. I thought this would be a variation of the tail command, but I can't find this anywhere.
Yarin
  • 173,523
  • 149
  • 402
  • 512
1
2 3
68 69