Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 ?


share|improve this question
up vote 3 down vote accepted

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

share|improve this answer

The -f flag in tail means "Keep the tail process running and if the file changes, chuck them onto STDOUT". 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 into awk. Because of the -f flag, tail never quits (until you tell it) so nothing ever gets piped into awk. 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...

share|improve this answer
Nope, pipe won't wait for the first program. There might be some buffer, but I've never faced any problems and noticeable delays with it using tail -f <something> | grep <...> or tail -f <something> | awk <...> – rvs Mar 23 '11 at 10:42
I stand corrected. – growse Mar 23 '11 at 10:55

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}'"

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.