r/linux • • Mar 30 '15

Stop using tail -f (mostly)

http://www.brianstorti.com/stop-using-tail/
830 Upvotes

219 comments sorted by

View all comments

29

u/allcentury Mar 30 '15

Tail -f within a tmux pane allows me to search just fine

19

u/qwertyboy Mar 30 '15

But it will still not let you scroll above the original tail.

5

u/CaptSpify_is_Awesome Mar 30 '15

True, but most of the time when I'm doing tail -f, I don't need the entire log. It can even be problematic, like if the original log is really large.

5

u/_riotingpacifist Mar 30 '15

tail -F -n +1

Seriously though, I've been feeling dirty doing that so might use this tip instead

0

u/socium Mar 30 '15

Depends. I fired up Lubuntu 14.04 recently and with the default terminal provided there I remember doing so without a hassle.

7

u/DavidA2001 Mar 30 '15

You can't scroll back in the log file more then the 10? Lines of context tail gives you. You can of course scroll back in your tmux history to see previous commands but you can't look further back in the log file then 10 lines before the moment you invoked tail.

4

u/lennort Mar 30 '15

True, but you can always specify a few more lines for your original context if you know you'll need it later.

tail -n 100 -F filename

2

u/DavidA2001 Mar 30 '15

Yes. I think the idea is if you're trying to figure out what's wrong you won't know before you start if you need more context.

I'll admit I go with tail -f initially, but less with S to chop long lines and F to go to the end and follow is what I do of that doesn't immediately clarify things.

1

u/renrutal Mar 31 '15
tail -Fn1000 server1.out -Fn500 server2.log

When you need only the last 1000 or 500 lines of two different files.

1

u/DavidA2001 Mar 31 '15

Tail wins if you want to open 2 files. The way less handles multiple files is sequential: you can't see them both at the same time.

I just don't think you can usually predict when you'll need more context. And when you find you need more context in this one particular file, you should probably switch to less.

-1

u/petepete Mar 30 '15

ctrl+b [ in tmux puts you into pager mode and you can scroll up as far as you want.

5

u/irishsultan Mar 30 '15

Not to the lines of the log file that were never printed by tail because they were logged before you started to tail -f

6

u/port53 Mar 30 '15

tail -n+0 -f <file> will give you the entire file, and then tail-follow it.