5

I want to tail -f a file that may contain very long lines. I would also like to see one line per screen line and scroll to the side if necessary, much like Vim's zL and zH, so no line wrapping,

Is there a way to accomplish this? Ideally without using vim or emacs to do the trick. Using another Terminal emulator is fine, but I'm on a Mac (using iTerm2 now).

6
  • So like less -S. Would perhaps tail -f <filename> | less -S work?
    – Dan D.
    Mar 4 '14 at 20:38
  • lees -S seems to still wrap the lines. No idea why. Also -S just cuts the end of the line, so I cannot retrieve the value in less any more, if I understand -S correctly.
    – mmlac
    Mar 4 '14 at 21:24
  • Have you tried making your terminal window wider than the lines? Just make it extend beyond the limits of your screen.
    – terdon
    Mar 4 '14 at 21:36
  • Yes, but some lines are a thousand characters or more (JSON Arrays, etc) and I would love to be able to go thorough the content on demand but not clutter up my normal view on the logs
    – mmlac
    Mar 4 '14 at 21:44
  • I very rarely need this, I tend to want the whole thing in one line but the wrapping is usually handled by the terminal emulator and depends on the size of the window. A thousand characters is not that long, you should be able to make the window wide enough for that. However, bear in mind that if you need to do this often, you are using the wrong tool for the job and a text editor would be better.
    – terdon
    Mar 4 '14 at 21:48
3

less -S truncates long lines disabling line wraps. You can however use the left and right arrow keys to see the truncated content

less also has a follow feature which allows it to tail updates to a file.

To activate it use SHIFT f once you are viewing the file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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