If I run
sudo pico /var/log/lighttpd/website/error.log
I get a very long file, and I cannot see last lines. If I run:
sudo tail -f /var/log/lighttpd/website/error.log | awk '{print $1 "--" $2}'
I don't get anything ? What am I doing wrong ?
Also, how can I move to a specific line using pico editor ?
thanks
You would better to use some pager program like
less
. It tries not to load the whole file into memory, so it works well with large files. In less you can move to a specific line by typing:123
where 123 is line number you need.As for tail - are you getting anything without awk? Or with
sudo tail -n 10 -f <log>
?The
-f
flag in tail means "Keep the tail process running and if the file changes, chuck them ontoSTDOUT
". Basically, it's a neat way of actively watching a log file.I believe the pipe will wait for the first program to finish writing to
STDOUT
before throwing the output intoawk
. Because of the-f
flag, tail never quits (until you tell it) so nothing ever gets piped intoawk
. Therefore nothing gets printed.Try the second command without the
-f
. If you're looking for-f
functionality but also with mangling the output with awk, I'm not sure what the answer is, short of writing a custom script to do it...tail -f
never quits as long as the file still exists (and I think after that too). Nothing gets passed through the pipe until the first process has died.If you want the functionality of tail -f (i.e. monitoring the file) while still piping it through awk, try
watch "tail /var/log/lighttpd/website/error.log | awk '{print \$1 \"--\" \$2}'"