Hot answers tagged


Surround the command with quotes watch -n 1 'tail -n 200 log/site_dev.log | fgrep Doctrine'


Some implementations of tail have an option for this; here's the description from the man page for GNU tail: -F same as --follow=name --retry -f, --follow[={name|descriptor}] output appended data as the file grows; -f, --follow, and --follow=descriptor are equivalent --retry keep trying to open a file even when it is or becomes ...


You are probably looking for some combination of messages from various log files. Try: tail -f /var/log/{messages,kernel,dmesg,syslog} …to get a pretty good overview of the system. If you want more or less than that, research what log file the messages you want to see are being placed in. Also look into using multitail to file and color code and filter ...


Alternative is tail -F command. The -F option implies --follow=name with --retry option, so tail is watching your file even if it has been deleted and created again.


Just make it @#$%ing work You want to print output of dmesg, constantly, immediately Dmesg is printing the kernel ring buffer (see man dmesg) The kernel ring buffer is a special proc file, /proc/kmsg (see man proc) Read /proc/kmsg directly, ie cat /proc/kmsg. Now, if you read the friendly proc manual, it'll sternly warn you to let only one user (who must ...


You almost wrote the answer, which is : tail -f file.log | grep "foobar" That's it.


The accepted answer isn't working for me, plus it's confusing and it changes the log file. I'm using something like this: tail -f logfile.log | while read LOGLINE do [[ "${LOGLINE}" == *"Server Started"* ]] && pkill -P $$ tail done If the log line matches the pattern, kill the "tail" started by this script. Note: if you want to also view the ...


You can run less +F filename in order to view file in tail -f fashion. You can press Shift+F while viewing file in less to switch to forwarding mode, and Ctrl+C to leave this mode.


-f follows by inode. If you want to follow by name, such as when a program completely recreates the file, then use -F instead.


For those interested in linux, since kernel kernel 3.5.0: # dmesg -w Also on systems with systemd you can: # journalctl -kf


This works: while ! tail -f bar/somefile.log ; do sleep 1 ; done


Here's a variant on djeikyb's answer that's actually tested, and fixes a couple of bugs. watch 'sudo dmesg -c >> /tmp/dmesg.log; tail -n 40 /tmp/dmesg.log' The important trick is that we're doing dmesg -c, which clears the ring buffer after it prints -- thus, each time through we're only printing what's new since the last time. You'll need to be ...


Using Windows Powershell, you can use Get-Content < filename > -wait There's also a discussion of a Windows Server 2003 tools package that has a tail program which supports -f


There already is a nice tool for that: split > man 1 split NAME split -- split a file into pieces SYNOPSIS split [-l line_count] [-a suffix_length] [file [prefix]] split -b byte_count[K|k|M|m|G|g] [-a suffix_length] [file [prefix]] split -p pattern [-a suffix_length] [file [prefix]] split --bytes 50M test.out test.out_ would ...


Try watch. Taken from here: watch -d ls -l A friend and I tried this a moment ago, it seems that the highlighting doesn't really work correctly, it will highlight a seemingly random selection. I've tried this in an OS X Terminal ssh'd to a RHEL5 machine and my friend has tried in a Ubuntu GUI terminal. Unfortunately inotifywait is not present on the ...


You're not mentioning which OS you need it for, but tailon linux has the --retry and --follow options that will do just that; tail --retry --follow=name somefile.log


If you have GNU head, you can use head -n -5 file.txt to print all but the last 5 lines of file.txt. If head -n takes no negative arguments, try head -n $(( $(wc -l file.txt | awk '{print $1}') - 5 )) file.txt


View > Clear Scrollback or press ⌘K


I might be wrong, but wouldn't this achieve the same thing more simply? tail -f -n 200 log/site_dev.log | grep Doctrine


You should use sed. sed -n -e 45000000,45000100p -e 45000101q bigfile > savedlines This tells sed to print lines 45000000-45000100 inclusive, and to quit on line 45000101.


There are a few ways to get tail to exit: Poor Approach: Force tail to write another line You can force tail to write another line of output immediately after grep has found a match and exited. This will cause tail to get a SIGPIPE, causing it to exit. One way to do this is to modify the file being monitored by tail after grep exits. Here is some ...


tail supports several files, for example: tail -q -f file1 file2


I have had good luck with It has some nice options for fonts, colors and keyword highlighting. Feels lightweight and fast to me.


From the tail man page: The tail utility displays the contents of file or, by default, its standard input, to the standard output. The display begins at a byte, line or 512-byte block location in the input. Numbers having a leading plus ("+") sign are relative to the beginning of the input, for example, "-c +2" starts the display at the second byte ...


tail -f mylogfile & sleep 60; kill $!


So after doing some testing, I found a quick 1-line way to make this work. It appears tail -f will quit when grep quits, but there's a catch. It appears to only be triggered if the file is opened and closed. I've accomplished this by appending the empty string to the file when grep finds the match. tail -f logfile |grep -m 1 "Server Started" | xargs echo ...


$ dd if=big_file.bin skip=1750 ibs=1MB count=10 of=big_file.bin.part You might want to spend some time reading and understanding dd.


inotifywait from inotify-tools shows a real-time log of file modifications, similar to tail -f. inotifywait -m -q -e create,delete,move /dir -r can be added for recursive watches (can be a little slow with many subdirectories), --format to change the output format (e.g. add timestamps or join the path & filename). Example output: ...


I have written a little Perl script that changes the colors of text matching a user defined regular expression. Here's the script: #!/usr/bin/env perl use Getopt::Std; use strict; use Term::ANSIColor; my %opts; getopts('hic:l:',\%opts); if ($opts{h}){ print<<EoF; Use -l to specify the pattern(s) to highlight. To specify more than one ...

Only top voted, non community-wiki answers of a minimum length are eligible