Tag Info

Hot answers tagged


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


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 ...


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.


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.


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 ...


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


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 ...


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


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


View > Clear Scrollback or press ⌘K


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


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.


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


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


I have had good luck with http://sourceforge.net/projects/tailforwin32/. 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 ...


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 ...


Try using the watch command with ls: $ watch ls -l watch will repeatedly execute the given command at regular (2 second) intervals, which can be configured through command-line options.


$ 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: ...


Create a MySQL database with a single table which has a single field. Then import your file into the database. This will make it very easy to look up a certain line. I don't think anything else could be faster (if head and tail already fail). In the end, the application that wants to find line n has to seek through the whole file until is has found n ...


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 ...


From less -help: F Forward forever; like "tail -f". so presumably less +F /var/log/messages


On Linux, use inotify-tools: inotifywait -qme create,attrib,move,delete mydir | while read -r; do clear ls -l mydir done Somewhat different: inotifywait -qme create,attrib,move,delete --format '%w%f' mydir | while read -r file; do ls -ld "$file" done


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 ...

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