Tag Info

Hot answers tagged

33

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


31

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


26

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


15

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


14

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


14

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


13

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


12

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


11

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


11

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


9

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


9

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


8

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


7

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.


7

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.


7

View > Clear Scrollback or press ⌘K


7

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


6

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


6

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.


6

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


6

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


6

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


5

Just use the tail program from the cygwin project. this is "just" a ported UN*X tail command.


5

tail -f mylogfile & sleep 60; kill $!


5

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


5

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


5

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


4

You could use sed if you know the lines you want. sed -n X,Yp file.txt Or if it's stuff between some REGEX, with awk: awk '/FIRST REGEX/,/LAST REGEX/' input.txt Or an awk way of doing the sed suggestion: awk 'NR>=X && NR<=Y' file.txt


4

tail itself doesn't have a line numbering capability, but other utilities do. This is a typical solution: cat -n process.logfile | tail


4

From the manpage: If the first character of N (the number of bytes or lines) is a `+', print beginning with the Nth item from the start of each file, other- wise, print the last N items in the file. N may have a multiplier suf- fix: b 512, k 1024, m 1024*1024.



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