The tail tag has no wiki summary.
63
votes
12answers
13k views
How to have tail -f show colored output
I'd like to be able to tail the output of a server log file that has messages like:
INFO
SEVERE
etc, and if it's SEVERE, show the line in red; if it's INFO, in green. What kind of alias can I ...
18
votes
4answers
3k views
How to obtain inverse behavior for `tail` and `head`?
Is there a way to head/tail a document and get the reverse output; because you don't know how many lines there are in a document?
I.e. I just want to get everything but the first 2 lines of foo.txt ...
16
votes
3answers
4k views
How does the “tail” command's “-f” parameter work?
$ tail -f testfile
the command is supposed to show the latest entries in the specified file, in real-time right? But that's not happening. Please correct me, if what I intend it to do is wrong...
I ...
16
votes
5answers
1k views
Is there a way to make tail -F beep?
Is there a way to make tail -F or less beep (ring the bell in a terminal) when new data comes in (a new line is added to the file).
Or is there any other unix utility to do this on a linux or mac.
15
votes
3answers
973 views
Piping from grep to awk not working
I am trying to grep the ongoing tail of file log and get the nth word from a line. Example file:
$ cat > test.txt <<EOL
Beam goes blah
John goes hey
Beam goes what?
John goes forget it
Beam ...
14
votes
1answer
1k views
How to do a `tail -f` of log rotated files?
On a long running system I usually have a terminal with
$ tail -f /var/log/kern.log
or something like this open.
But from time to time I have to restart such command because no new messages are ...
11
votes
6answers
2k views
Command to display first few and last few lines of a file
I have a file with many rows, and each row has a timestamp at the starting, like
[Thread-3] (21/09/12 06:17:38:672) logged message from code.....
So, I frequently check 2 things from this log file.
...
11
votes
4answers
281 views
How to do a continous 'wc -l' with gnu texttools?
I know of course that
cat logfile.txt | wc -l
120
will tell me the number of lines in a file.
Whereas
tail -f logfile.txt
will show me the new lines that another program writes to logfile.txt.
...
10
votes
7answers
6k views
grep and tail -f?
Is it possible to do a tail -f (or similar) on a file, and grep it at the same time? I wouldn't mind other commands just looking for that kind of behavior.
10
votes
2answers
609 views
monitor files (ala tail -f) in an entire directory (even new ones)
I normally watch many logs in a directory doing tail -f directory/*.
The problem is that a new log is created after that, it will not show in the screen (because * was expanded already).
Is there a ...
9
votes
4answers
2k views
How to monitor only the last n lines of a log file?
I have a growing log file for which I want to display only the last 15 lines. Here is what I know I can do:
tail -n 15 -F mylogfile.txt
As the log file is filled, tail appends the last lines to the ...
9
votes
5answers
1k views
Best way to follow a log and execute a command when some text appears in the log
I have a server log that outputs a specific line of text into its log file when the server is up. I want to execute a command once the server is up, and hence do something like the following:
tail -f ...
9
votes
1answer
1k views
How do I make a shell script that sends output to a process
I'm currently running a server console program in a screen because I need to both read it and occasionally send commands.
I'd like to run the app as a deamon in the background (start/stop it with ...
8
votes
1answer
155 views
How to start tailing a file that has not been yet created
I use tail to monitor the progress of jobs that I know will write their progress to disk. Almost always, I know which file they will create before they start running (the jobs are dispatched by a ...
8
votes
2answers
622 views
How to have tail -f show colored output with vim?
In this question, Gilles answered
Yet another possibility is to run tail -f in an Emacs shell buffer and use Emacs's syntax coloring abilities.
Because I'm a vim user, I'd like to do this with ...
7
votes
4answers
577 views
What is the easiest way to execute text from tail at the command line?
Sometimes I'm working on a new (ubuntu) box and I type git and am alerted:
The program 'git' is currently not installed. You can install it by typing:
apt-get install git-core
If that happens I ...
7
votes
2answers
447 views
“tail -f | iconv -fsjis” does not output anything
I want to tail -f a file, but its content is in sjis encoding, so I need to have it converted to the native (utf-8) encoding of my terminal.
When I do
tail -f x | iconv -fsjis
there will be no ...
6
votes
4answers
4k views
cat line X to line Y on a huge file
Say I have a huge text file (>2GB) and I just want to cat the lines X to Y (e.g. 57890000 to 57890010).
From what I understand I can do this by piping head into tail or viceversa, i.e.
head -A ...
6
votes
1answer
60 views
How to do `head` and `tail` on null-delimited input in bash?
find command can output names of files as a null-delimited strings (if -print0 is provided), and xargs can consume them with -0 option turned on. But in between, it's hard to manipulate that ...
4
votes
3answers
283 views
How can I do the equivalent of tail -f with ls? [duplicate]
Possible Duplicate:
Is it possible to follow a command (run repeatedly)? as one would follow a file using tail -f?
I would like to monitor files that are being downloaded to a directory in ...
4
votes
1answer
1k views
Reading from a continuously changing logfile
There is /location/of/thefile, which is a continuously changing logfile. The average density of refreshes is 4 per minute, the possible maximal refresh rate could be 30-40 per minute. Every refresh ...
4
votes
4answers
534 views
`tail -f` until text is seen
I've got a CI server with a command-line interface that allows me to remotely kick-off a job (jenkins CI server and the jenkins-cli.jar tool).
After I kick the job off I tail -f the log (sorry for ...
4
votes
2answers
274 views
Is it possible to follow a command (run repeatedly)? as one would follow a file using tail -f?
I have a script which produces a file 'Detail.out'. I know that the script is completed whenever the file contains a certain number of lines (roughly 21025). So I find myself sitting at the command ...
4
votes
1answer
157 views
What's a convenient way of checking what's being added to a log file in realtime?
Right now I'm essentially executing tail /var/log/syslog manually every once in a while. Is there something that lets me see what's being added continuously, or do I need to write something myself?
4
votes
1answer
150 views
Observe multiple log files in one output
Is there an easy way to do something like tail -f mylogfile but to have the changes of more than one file displayed (maybe with the file name added as prefix to each line)? Or maybe a GUI tool? I am ...
4
votes
2answers
466 views
Moving average on a log file with awk or other unix utilities?
Scenario:
I have a log file that has a few number of entry "classes", like this:
R0 dx=0.00500 rb=0.00000 sn=1 3145.88 2.59 0.08 se=21315 id=16190
R0 dx=0.00300 rb=-1.00000 sn=1 3150.40 2.38 0.05 ...
4
votes
2answers
718 views
Follow a pipe using less?
Can less follow (by pressing F) a piped input (similarly to a file)?
For a file that is being written to, the command
less <file>
will follow the file when pressing F.
But if I have a ...
4
votes
0answers
66 views
Combing head and tail in a single call via pipe [duplicate]
On a regular basis, I am piping the output of some program to either head or tail.
Now, suppose that I want to see the first AND last 10 lines of piped output, such that I could do something like
...
3
votes
6answers
872 views
Is it possible to “roll” a symlink to a new file without affecting any open file handles?
An application I am developing locally logs it's output to files formatted with the current timestamp such as app-%Y%m%d.log.
To make it simple to be able to tail the current's day log in a terminal ...
3
votes
1answer
107 views
Why does tailing an output log sometimes give partial lines?
Sometimes, tailing an output log which is constantly being updated doesn't give the whole lines. Why is that?
grep pattern input_file > output.log &
tail output.log
Why doesn't it print the ...
3
votes
1answer
170 views
limit stdout to terminal output speed [duplicate]
Possible Duplicate:
How can I limit the output speed of stdout?
What's the easiest way to limit the speed at which stdout is output in a terminal, so that, for instance, tail -f outputs ...
3
votes
2answers
80 views
Output the changes to a log file
If I use
tail -f *filename*
I get a real nice display of whatever is changing in a given file. However, sometimes I want to be able to search this text or otherwise look it over slowly.
Is ...
3
votes
1answer
512 views
How to follow (a la “tail -f”) a binary file from the beginning?
Is it possible to follow a binary file from the beginning, a la tail -f?
This is useful in some cases, for example if I'm scping a file to a remote server, and at the same time I want to feed it to ...
3
votes
2answers
304 views
How to make dot matrix printer print every line of 'tail -f'
I have a dot matrix printer, an Epson LQ-500.
It works well with CUPS, and I use it to print listings sometimes, text files, etc.
now, I'd like to use it as a logging printer. for that, I need it to ...
2
votes
2answers
95 views
Tail -f piped through grep not outputing to file, but outputs to console
I'm using the following command
tail -f /mydir/myfile | grep "searchterm" >> outfile
Without the -f it works fine, but with the -f, which I need, nothing is written to the file. The ...
2
votes
3answers
649 views
Is it fine to use tail -f on large log files
I would like monitor a large log file (close to 1 GB) for errors. I want this to be close to real time (few seconds delay is fine). My plan is to use tail -f | grep. Is there any performance issues ...
2
votes
1answer
27 views
Making less's follow option show line movement
I often find myself using less to display log files that contain hundreds of
contiguous, identical lines that are appended to the files at set intervals.
For example,
something happened
something ...
2
votes
3answers
386 views
How do I tail a log file and keep tailing it when the latest one changes date?
I'm using RHEL 4.
The normal tail -F file_name*.log doesn't update when the time flips over to 0000.
Here's what I've tried so far from searching the web, both of which try to use nested tail:
...
2
votes
2answers
2k views
Add carriage return to output of `tail` while using `grep`
I'm looking to refactor the following command:
tail -f production.log |
grep -e "Processing " -e "compatible;" -e "Completed in " -e
This is the output of the command:
Processing ...
2
votes
1answer
65 views
Does multitail follow the inode or the file name by default?
For logrotated files one usually uses tail -F instead of tail -f to follow the log file contents. Does multitail(1) automatically follow the name instead of the inode (which likely changes with the ...
2
votes
2answers
796 views
How to execute this particular shell command from Python?
OK, so, I have this non-functional shell script, which I am rewriting piece by piece in python, except I am getting an "unexpected "|" error" from the shell (see below):
#/bin/sh
LINES=`cat $@ | wc ...
1
vote
2answers
160 views
How to use tail -f with grep to show surrounding lines
I would like to see the output in a logfile greped by only one domain but also the following two lines.
Example:
tail -f /var/log/apache2/modsec_audit.log |grep mydomain.de
this shows all lines, ...
1
vote
4answers
823 views
How to limit the number of lines a command's output has available in bash?
I started downloading a big file in the background using
$ nohup wget http://example.tld/big.iso &
which also gives me a nohup.out file that includes the output of wget.
Now, if I later want ...
1
vote
1answer
250 views
How to tail/grep/awk the last N bytes of a file, rather than lines
I have an application that is logging to a plain text log file (myapp.log) but it doesn't seem to be writing new line characters at the end of each log entry. If I execute a command like tail -n 50 ...
1
vote
3answers
214 views
Is there a way to beep when tail -F stops to fetch new results?
A few days ago I asked Is there a way to make tail -F beep?
Now I want to know if there is any way to use *nix utilities, to beep when a tail -F stops returning new lines for a while!
I know, I ...
1
vote
2answers
57 views
tail -f but suck in content of the file first (aka `cat -f`)
I need to display whole file before tracking it for a new changes, not only the last 10 lines (yep, I know it's not tail conceptually). In other words, something like cat -f would do, if it would ever ...
1
vote
3answers
166 views
How to view output for ALL processes simultaneously?
I know that you can connect to various background processes to watch their console output, but is there a way to view the output of all processes at once? Likely it would scroll quickly and be hard to ...
1
vote
2answers
398 views
Is there any other way to use tail -f for grep -q && operation?
I found this solution:
http://stackoverflow.com/questions/7178888/grep-q-not-exiting-with-tail-f
but is there any other possible?
UPD: I want to do tail -f | grep -q something && echo ...
1
vote
1answer
746 views
Flush 'tail -f' buffer?
I'm using the following statement (simplified version):
tail -f -c+1 <filename>
in order to pipe a file to a process.
What I've found, though, is that there is a number of lines at the end ...
1
vote
1answer
54 views
Can I use tail with a file both as input and destination?
I have a log file that gets big fast. I tried using tail with this syntax but it didn't work.
tail logfile.log -n 100000 > logfile.log
The output file is 0 bytes and blank. What am I doing ...