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
17
votes
9 answers

Binary "tail" a file

I would guess most people on this site are familiar with tail, if not - it provides a "follow" mode that as text is appended to the file tail will dump those characters out to the terminal. What I am looking for (and possibly to write myself if…
Goyuix
  • 23,614
  • 14
  • 84
  • 128
17
votes
4 answers

How do you continuously read a file in Java?

I'm trying to figure out how to continuously read a file and once there is a new line added, output the line. I'm doing this using a sleep thread however it just seems to blow through the whole file and exit the program. Any suggestions what I'm…
phill
  • 13,434
  • 38
  • 105
  • 141
17
votes
3 answers

Powershell - Tail Windows Event Log? Is it possible?

How can i use powershell to tail a specific windows event log? Is it possible?
TheOneTeam
  • 25,806
  • 45
  • 116
  • 158
17
votes
6 answers

How To watch a file write in PHP?

I want to make movement such as the tail command with PHP, but how may watch append to the file?
freddiefujiwara
  • 57,041
  • 28
  • 76
  • 106
17
votes
2 answers

How to tail the last line of multiple files using "tail -1 */filename"

tail */filename works, but tail -1 */filename doesn't. Why is this? And is there a 1 liner to perform this task without loops? head -1 */filename works for some strange reason.
mrkent
  • 333
  • 2
  • 4
  • 13
16
votes
2 answers

Tailing Rolling Files

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…
user1118047
  • 189
  • 2
  • 6
16
votes
5 answers

Print first few and last few lines of file through a pipe with "..." in the middle

Problem Description This is my file 1 2 3 4 5 6 7 8 9 10 I would like to send the cat output of this file through a pipe and receive this % cat file | some_command 1 2 ... 9 10 Attempted solutions Here are some solutions I've tried, with their…
Sam
  • 1,765
  • 11
  • 82
  • 176
15
votes
6 answers

How can I remove all but the last 10 lines from a file?

Is it possible to keep only the last 10 lines of a lines with a simple shell command? tail -n 10 test.log delivers the right result, but I don't know how to modify test.log itself. And tail -n 10 test.log > test.log doesn't work.
user455765
15
votes
2 answers

Tail -f - Show last X lines that match a pattern

I'm trying to achieve the equivalent of tail -f -n10 for a matched pattern. At first I thought tail -f -n10 | grep PATTERN but that only returns lines that match the pattern in the last 10 lines of the file. What I'm looking for is the last ten…
docksteaderluke
  • 2,195
  • 5
  • 27
  • 38
15
votes
3 answers

How can I follow a file like "Tail -f" does in Java without holding the file open (Prevent rename/delete)

i'd like to "Tail -f" a lot of logfiles from within a java app. I've gotten this to work by monitoring the size and last update and repeatedly opening the file and reading the last few bytes whenever the file size or last update time changes--then…
Bill K
  • 62,186
  • 18
  • 105
  • 157
15
votes
5 answers

Shell function to tail a log file for a specific string for a specific time

I need to the following things to make sure my application server is Tail a log file for a specific string Remain blocked until that string is printed However if the string is not printed for about 20 mins quit and throw and exception message like…
pup784
  • 533
  • 3
  • 5
  • 15
14
votes
4 answers

How does erlang handle case statements mixed with tail recursion

Let's say I have this code here: do_recv_loop(State) -> receive {do,Stuff} -> case Stuff of one_thing -> do_one_thing(), do_recv_loop(State); another_thing -> do_another_thing(), …
Mediocre Gopher
  • 2,274
  • 1
  • 22
  • 39
14
votes
4 answers

How to get the last lines of a file except the first 20?

Say I have a file with any number of lines, say, 125. I want to get all the lines except the first n, say, 20. So, I want lines 21–125. Is there a way to do this with with tail/head, or some other tool?
kch
  • 77,385
  • 46
  • 136
  • 148
14
votes
2 answers

What is difference between tail -f and tailf in unix?

I try to show tail of a text file. If file is small, there is no difference. However if file is too big (~5 gB), tailf does not respond. On the other hand tail -f works fine. What is difference between them?
umut
  • 1,016
  • 1
  • 12
  • 25
13
votes
2 answers

Permanent fix to tail: cannot watch `log/development.log': No space left on device

I've been using Ubuntu 11.10 for a little over a week now. But after some time I encountered this error(the one in the title) when Im trying to access the log in my RoR project. I found a fix which is by pasting this in the terminal: sudo sysctl…
Normz
  • 271
  • 1
  • 2
  • 9