Questions tagged [tail]

Unix command to view the end of a file

tail is a Unix command that views the last few lines of a file. It can also be used to watch a log file as it grows.

tail is commonly provided by GNU .

140 questions
226
votes
4 answers

Using watch with pipes

I'd like to run this command: watch -n 1 tail -n 200 log/site_dev.log | grep Doctrine But it does not run, because "I think" that the grep tries to run on the watch instead of the tail... Is there a way to do something like watch -n 1 (tail -n 200…
Tommy B.
  • 2,609
209
votes
17 answers

Is it possible to `tail -f` the output of `dmesg`?

I want to do something like dmesg | tail -f but it doesn't work: I use Mac OS X v10.6.7 (Snow Leopard). By doing that, tail will exit, instead of monitoring the output. I wonder if there is a way to do it, or an equivalent command. P.S., I don't…
Ivan Xiao
  • 2,945
93
votes
6 answers

Opposite of tail: all lines except the last n lines

How can I discard the last n lines of a file with a unix command line filter? That would be sort of the opposite of tail: tail discards the first n lines but pipes the rest through, but I want the command to pipe everything through except the last n…
88
votes
22 answers

Monitoring a file until a string is found

I am using tail -f to monitor a log file that is being actively written to. When a certain string is written to the log file, I want to quit the monitoring, and continue with the rest of my script. Currently I am using: tail -f logfile.log | grep -m…
62
votes
6 answers

Alternative for "tail -f" that follows filename

I have some logs being generated using a timed rotating file logger. This logs to a file called tool.log, and at midnight, moves this to tool.log. and starts a new tool.log. I have a tail -f tool.log running on the machine to keep an eye on…
Hugh
  • 1,591
41
votes
3 answers

How to make tail wait for the file to exist so it follows it?

tail -f bar/somefile.log would fail immediately when somefile.log does not exist. How do I make tail indefinitely wait for that file to be created (which will happen in a few moments)? Update: using -F, I see: tail: cannot open `bar/somefile.log'…
34
votes
1 answer

Combine tail -f with grep?

Hi I wanna keep looking at a log file, but I also don't wanna see irrelevant stuff, I'm only interested in anything with "foobar" in it. So if I was tailing the file I would do tail file | grep "foobar" Now that I'm adding the -f option, is there…
user893730
  • 1,267
29
votes
2 answers

tail/head all line except X last/first Lines

for example i have this file : cat myfile 1 2 3 4 5 i want to print all lines except first 2 line . output should be like this : tail -n $(( $(wc -l myfile | awk '{print $1}') - 2 )) myfile 3 4 5 Yes , out put is correct. but there is a problem ,…
network
  • 401
  • 1
  • 4
  • 4
27
votes
4 answers

tail -f not tracking file changes

I was recently looking into using tail -f to monitor some text files like so: tail -f /var/sometext. However, when I did some testing, it doesn't seem to work. What I did was I created a new file and ran: tail -f /home/name/text Then, I opened the…
Vince Tar
24
votes
4 answers

Using 'head' or 'tail' on HUGE text file - 19 GB

I have a problem with viewing chunks of a very large text file. This file, approximately 19 GB, is obviously too big to view by any traditional means. I have tried head 1 and tail 1 (head -n 1 and tail -n 1) with both commands piped together in…
nicorellius
  • 6,815
22
votes
9 answers

Windows XP equivalent of "tail -f"?

Is there way have windows XP show me updates to a log file as they happen? I'm thinking of something similar to tail -f in the linux realm.
Mike B
  • 2,720
22
votes
4 answers

appending timestamp to tail -f results

I would like to have a timestamp printed in front of every line that comes out of a "tail -f outputfile", so that I know when is each line printed in. Something like: [...] 20110617_070222:results printed here 20110617_070312:results printed…
719016
  • 4,683
19
votes
4 answers

Linux command line log viewer which allows auto tail AND searching?

I use tail -f in my Linux shell, to view log files, as I like how it auto-updates with the incoming text: I like to see the new stuff come scrolling in. However, I also like the search functionality of less, which isn't available in tail (or is…
Max Williams
  • 3,129
16
votes
3 answers

Stop scrolling to the bottom automatically in PuTTY

I am using tail -f to monitor a file via PuTTY. But each time new content arrives then it automatically scrolls to the bottom and so I can't read the text. Is there a way to make it stop that behaviour?
Black
  • 8,671
14
votes
2 answers

Equivalent of 'clear' command when using tail -f

I am using the tail -f command to follow an error log, and I often want to "clear" the terminal, much in the same way that the clear unix command moves everything above the top of the window. Is there something like this when using tail? At the…
1
2 3
9 10